From 6c77002e3084d51a10035c3804184fb85ecd827e Mon Sep 17 00:00:00 2001 From: Lars Lauger Date: Wed, 30 Oct 2024 17:29:45 +0100 Subject: [PATCH] fix: Repair tests for dbal 3.8+ --- test/UpsertTest.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/UpsertTest.php b/test/UpsertTest.php index 9e7cb30..77c03b4 100644 --- a/test/UpsertTest.php +++ b/test/UpsertTest.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception as DBALException; -use Doctrine\DBAL\ForwardCompatibility\DriverResultStatement; +use Doctrine\DBAL\Result; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -211,7 +211,7 @@ public function Table_Name_is_used_in_Query(): void public function Insert_works(): void { $connection = $this->getSQLiteConnection(); - $connection->exec('CREATE TABLE foo_table(bar TEXT PRIMARY KEY, count INT);'); + $connection->executeStatement('CREATE TABLE foo_table(bar TEXT PRIMARY KEY, count INT);'); Upsert::fromConnection($connection) ->forTable('foo_table') @@ -219,12 +219,12 @@ public function Insert_works(): void ->withField('count', 1) ->execute(); - $values = $connection->fetchAll('SELECT * FROM foo_table'); + $values = $connection->fetchAllAssociative('SELECT * FROM foo_table'); self::assertCount(1, $values); self::assertSame( [ 'bar' => 'baz', - 'count' => '1' + 'count' => 1 ], $values[0] ); @@ -236,8 +236,8 @@ public function Insert_works(): void public function Upsert_works(): void { $connection = $this->getSQLiteConnection(); - $connection->exec('CREATE TABLE foo_table(bar TEXT PRIMARY KEY, count INT);'); - $connection->exec('INSERT INTO foo_table (bar, count) VALUES ("baz", 1)'); + $connection->executeStatement('CREATE TABLE foo_table(bar TEXT PRIMARY KEY, count INT);'); + $connection->executeStatement('INSERT INTO foo_table (bar, count) VALUES ("baz", 1)'); Upsert::fromConnection($connection) ->forTable('foo_table') @@ -245,12 +245,12 @@ public function Upsert_works(): void ->withField('count', 2) ->execute(); - $values = $connection->fetchAll('SELECT * FROM foo_table'); + $values = $connection->fetchAllAssociative('SELECT * FROM foo_table'); self::assertCount(1, $values); self::assertSame( [ 'bar' => 'baz', - 'count' => '2' + 'count' => 2 ], $values[0] ); @@ -258,7 +258,7 @@ public function Upsert_works(): void private function getSQLiteConnection(): Connection { - if (!extension_loaded('sqlite')) { + if (!extension_loaded('sqlite3')) { self::markTestSkipped('ext-sqlite3 is required for tests'); } @@ -294,9 +294,10 @@ private function getMockConnection() return $connection; } - private function getMockResult(int $rowCount): DriverResultStatement + private function getMockResult(int $rowCount): Result { - $result = $this->getMockBuilder(DriverResultStatement::class) + $result = $this->getMockBuilder(Result::class) + ->disableOriginalConstructor() ->getMock(); $result