Skip to content

Commit

Permalink
fix: Repair tests for dbal 3.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
paxuclus committed Oct 30, 2024
1 parent 5515982 commit 6c77002
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions test/UpsertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -211,20 +211,20 @@ 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')
->withIdentifier('bar', 'baz')
->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]
);
Expand All @@ -236,29 +236,29 @@ 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')
->withIdentifier('bar', 'baz')
->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]
);
}

private function getSQLiteConnection(): Connection
{
if (!extension_loaded('sqlite')) {
if (!extension_loaded('sqlite3')) {
self::markTestSkipped('ext-sqlite3 is required for tests');
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6c77002

Please sign in to comment.