mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-23 05:54:55 +00:00
Fix remaining tests
This commit is contained in:
parent
5d61ab0a57
commit
f3b0c791f8
3 changed files with 18 additions and 22 deletions
|
@ -90,25 +90,23 @@ abstract class BaseStatement extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
|
|
||||||
public function testBindMultipleValues() {
|
public function testBindMultipleValues() {
|
||||||
$exp = [
|
$exp = [
|
||||||
'one' => 1,
|
'one' => "A",
|
||||||
'two' => 2,
|
'two' => "B",
|
||||||
];
|
];
|
||||||
$exp = static::$stringOutput ? $this->stringify($exp) : $exp;
|
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two", ["str", "str"]));
|
||||||
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two", ["int", "int"]));
|
$val = $s->runArray(["A", "B"])->getRow();
|
||||||
$val = $s->runArray([1,2])->getRow();
|
|
||||||
$this->assertSame($exp, $val);
|
$this->assertSame($exp, $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBindRecursively() {
|
public function testBindRecursively() {
|
||||||
$exp = [
|
$exp = [
|
||||||
'one' => 1,
|
'one' => "A",
|
||||||
'two' => 2,
|
'two' => "B",
|
||||||
'three' => 3,
|
'three' => "C",
|
||||||
'four' => 4,
|
'four' => "D",
|
||||||
];
|
];
|
||||||
$exp = static::$stringOutput ? $this->stringify($exp) : $exp;
|
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two, ? as three, ? as four", ["str", ["str", "str"], "str"]));
|
||||||
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two, ? as three, ? as four", ["int", ["int", "int"], "int"]));
|
$val = $s->runArray(["A", ["B", "C"], "D"])->getRow();
|
||||||
$val = $s->runArray([1, [2, 3], 4])->getRow();
|
|
||||||
$this->assertSame($exp, $val);
|
$this->assertSame($exp, $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,18 +18,14 @@ class TestDriver extends \JKingWeb\Arsse\TestCase\Db\BaseDriver {
|
||||||
protected static $insertDefaultValues = "INSERT INTO arsse_test(id) values(default)";
|
protected static $insertDefaultValues = "INSERT INTO arsse_test(id) values(default)";
|
||||||
|
|
||||||
protected function exec($q): bool {
|
protected function exec($q): bool {
|
||||||
if (is_array($q)) {
|
if (!is_array($q)) {
|
||||||
$q = implode("; ", $q);
|
$q = [$q];
|
||||||
}
|
}
|
||||||
static::$interface->multi_query($q);
|
foreach ($q as $query) {
|
||||||
$e = null;
|
static::$interface->query($query);
|
||||||
do {
|
if (static::$interface->sqlstate !== "00000") {
|
||||||
if (!$e && static::$interface->sqlstate !== "00000") {
|
throw new \Exception(static::$interface->error);
|
||||||
$e = new \Exception(static::$interface->error);
|
|
||||||
}
|
}
|
||||||
} while (static::$interface->more_results() && static::$interface->next_result());
|
|
||||||
if ($e) {
|
|
||||||
throw $e;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
|
||||||
return "'".\IntlChar::chr((int) $match[1])."'";
|
return "'".\IntlChar::chr((int) $match[1])."'";
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
|
case "datetime":
|
||||||
|
return "cast($value as datetime(0))";
|
||||||
default:
|
default:
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue