mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +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() {
|
||||
$exp = [
|
||||
'one' => 1,
|
||||
'two' => 2,
|
||||
'one' => "A",
|
||||
'two' => "B",
|
||||
];
|
||||
$exp = static::$stringOutput ? $this->stringify($exp) : $exp;
|
||||
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two", ["int", "int"]));
|
||||
$val = $s->runArray([1,2])->getRow();
|
||||
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two", ["str", "str"]));
|
||||
$val = $s->runArray(["A", "B"])->getRow();
|
||||
$this->assertSame($exp, $val);
|
||||
}
|
||||
|
||||
public function testBindRecursively() {
|
||||
$exp = [
|
||||
'one' => 1,
|
||||
'two' => 2,
|
||||
'three' => 3,
|
||||
'four' => 4,
|
||||
'one' => "A",
|
||||
'two' => "B",
|
||||
'three' => "C",
|
||||
'four' => "D",
|
||||
];
|
||||
$exp = static::$stringOutput ? $this->stringify($exp) : $exp;
|
||||
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two, ? as three, ? as four", ["int", ["int", "int"], "int"]));
|
||||
$val = $s->runArray([1, [2, 3], 4])->getRow();
|
||||
$s = new $this->statementClass(...$this->makeStatement("SELECT ? as one, ? as two, ? as three, ? as four", ["str", ["str", "str"], "str"]));
|
||||
$val = $s->runArray(["A", ["B", "C"], "D"])->getRow();
|
||||
$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 function exec($q): bool {
|
||||
if (is_array($q)) {
|
||||
$q = implode("; ", $q);
|
||||
if (!is_array($q)) {
|
||||
$q = [$q];
|
||||
}
|
||||
static::$interface->multi_query($q);
|
||||
$e = null;
|
||||
do {
|
||||
if (!$e && static::$interface->sqlstate !== "00000") {
|
||||
$e = new \Exception(static::$interface->error);
|
||||
foreach ($q as $query) {
|
||||
static::$interface->query($query);
|
||||
if (static::$interface->sqlstate !== "00000") {
|
||||
throw new \Exception(static::$interface->error);
|
||||
}
|
||||
} while (static::$interface->more_results() && static::$interface->next_result());
|
||||
if ($e) {
|
||||
throw $e;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement {
|
|||
return "'".\IntlChar::chr((int) $match[1])."'";
|
||||
}
|
||||
return $value;
|
||||
case "datetime":
|
||||
return "cast($value as datetime(0))";
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue