Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All CI runs are using the sqlite fallback connection instead of the expected driver #8532

Merged
merged 3 commits into from Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions ci/github/phpunit/sqlite.xml
Expand Up @@ -7,6 +7,10 @@
failOnRisky="true"
>
<php>
<!-- use an in-memory sqlite database -->
<var name="db_driver" value="pdo_sqlite"/>
<var name="db_memory" value="true"/>

<!-- necessary change for some CLI/console output test assertions -->
<env name="COLUMNS" value="120"/>
</php>
Expand Down
42 changes: 28 additions & 14 deletions phpunit.xml.dist
Expand Up @@ -33,22 +33,36 @@

<php>
<!-- "Real" test database -->
<!-- uncomment, otherwise sqlite memory runs
<var name="db_type" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="root" />
<var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" />
<var name="db_port" value="3306"/>-->
<var name="db_driver" value="pdo_sqlite"/>
<var name="db_memory" value="true"/>
<!-- to use another database driver / credentials, provide them like so:
<var name="db_driver" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_user" value="root" />
<var name="db_password" value="" />
<var name="db_dbname" value="doctrine_tests" />
<var name="db_port" value="3306"/>-->
<!--<var name="db_event_subscribers" value="Doctrine\DBAL\Event\Listeners\OracleSessionInit">-->

<!-- Database for temporary connections (i.e. to drop/create the main database) -->
<var name="tmpdb_type" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_username" value="root" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_name" value="doctrine_tests_tmp" />
<var name="tmpdb_port" value="3306"/>
<!--
At the start of each test run, we will drop and recreate the test database.

By default we assume that the `db_` config above has unrestricted access to the provided database
platform.

If you prefer, you can provide a restricted user above and a separate `privileged_db` config
block to provide details of a privileged connection to use for the setup / teardown actions.

Note that these configurations are not merged - if you specify a `privileged_db_driver` then
you must also specify all the other options that your driver requires.

<var name="privileged_db_driver" value="pdo_mysql"/>
<var name="privileged_db_host" value="localhost" />
<var name="privileged_db_user" value="root" />
<var name="privileged_db_password" value="" />
<var name="privileged_db_dbname" value="doctrine_tests_tmp" />
<var name="privileged_db_port" value="3306"/>
-->

<env name="COLUMNS" value="120"/>
</php>
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/Locking/LockTest.php
Expand Up @@ -181,7 +181,7 @@ public function testLockPessimisticWrite(): void

$query = array_pop($this->_sqlLoggerStack->queries);
$query = array_pop($this->_sqlLoggerStack->queries);
$this->assertContains($writeLockSql, $query['sql']);
$this->assertStringContainsString($writeLockSql, $query['sql']);
}

/**
Expand Down Expand Up @@ -216,7 +216,7 @@ public function testLockPessimisticRead(): void
array_pop($this->_sqlLoggerStack->queries);
$query = array_pop($this->_sqlLoggerStack->queries);

$this->assertContains($readLockSql, $query['sql']);
$this->assertStringContainsString($readLockSql, $query['sql']);
}

/**
Expand Down
24 changes: 16 additions & 8 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH7941Test.php
Expand Up @@ -14,12 +14,12 @@
final class GH7941Test extends OrmFunctionalTestCase
{
private const PRODUCTS = [
['name' => 'Test 1', 'price' => '100', 'square_root' => '/^10(\.0+)?$/'],
['name' => 'Test 2', 'price' => '100', 'square_root' => '/^10(\.0+)?$/'],
['name' => 'Test 3', 'price' => '100', 'square_root' => '/^10(\.0+)?$/'],
['name' => 'Test 4', 'price' => '25', 'square_root' => '/^5(\.0+)?$/'],
['name' => 'Test 5', 'price' => '25', 'square_root' => '/^5(\.0+)?$/'],
['name' => 'Test 6', 'price' => '-25', 'square_root' => '/^5(\.0+)?$/'],
['name' => 'Test 1', 'price' => '100', 'square_root' => 10],
['name' => 'Test 2', 'price' => '100', 'square_root' => 10],
['name' => 'Test 3', 'price' => '100', 'square_root' => 10],
['name' => 'Test 4', 'price' => '25', 'square_root' => 5],
['name' => 'Test 5', 'price' => '25', 'square_root' => 5],
['name' => 'Test 6', 'price' => '-25', 'square_root' => 5],
];

protected function setUp(): void
Expand Down Expand Up @@ -51,7 +51,11 @@ public function typesShouldBeConvertedForDQLFunctions(): void

self::assertSame(6, $result['count']);
self::assertSame('325', $result['sales']);
self::assertRegExp('/^54\.16+7$/', $result['average']);

// Driver return type and precision is determined by the underlying php extension, most seem to return a string.
// pdo_mysql and mysqli both currently return '54.1667' so this is the maximum precision we can assert.
// See https://github.com/doctrine/orm/pull/8532#pullrequestreview-610037209
self::assertEqualsWithDelta(54.1667, $result['average'], 0.0001);

$query = $this->_em->createQuery(
'SELECT
Expand All @@ -66,7 +70,11 @@ public function typesShouldBeConvertedForDQLFunctions(): void

self::assertSame(ltrim($product['price'], '-'), $item['absolute']);
self::assertSame(strlen($product['name']), $item['length']);
self::assertRegExp($product['square_root'], $item['square_root']);

// Driver return types for the `square_root` column are inconsistent depending on the underlying
// database driver. Most return string (though some '10' and some '10.000000000000000') but at least mysqli
// returns a float.
self::assertEqualsWithDelta($product['square_root'], $item['square_root'], 0.00000001);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php
Expand Up @@ -54,9 +54,9 @@ class UUIDEntity
/**
* Get id.
*
* @return id.
* @return string.
*/
public function getId(): id
public function getId(): string
{
return $this->id;
}
Expand Down