diff --git a/tests/cases/Db/BaseStatement.php b/tests/cases/Db/BaseStatement.php index 6d19862..94922e6 100644 --- a/tests/cases/Db/BaseStatement.php +++ b/tests/cases/Db/BaseStatement.php @@ -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); } diff --git a/tests/cases/Db/MySQL/TestDriver.php b/tests/cases/Db/MySQL/TestDriver.php index 15b21c1..9b08395 100644 --- a/tests/cases/Db/MySQL/TestDriver.php +++ b/tests/cases/Db/MySQL/TestDriver.php @@ -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; } diff --git a/tests/cases/Db/MySQL/TestStatement.php b/tests/cases/Db/MySQL/TestStatement.php index 868a87f..ccda364 100644 --- a/tests/cases/Db/MySQL/TestStatement.php +++ b/tests/cases/Db/MySQL/TestStatement.php @@ -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; }