8000 minor #58578 [Cache] recreate the schema for every single test (xabbuh) · symfonyaml/symfony@5b30bc6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b30bc6

Browse files
committed
minor symfony#58578 [Cache] recreate the schema for every single test (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [Cache] recreate the schema for every single test | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The former test implementation relied on the order in which tests are executed assuming that tests explicitly creating the schema were executed first. This assumption leads to test failures on PHPUnit 10+ were tests defined in parent classes are run first where they were run later with PHPUnit 9.6. Commits ------- 633a60e drop existing schema if tests create it explicitly
2 parents c3b0509 + 633a60e commit 5b30bc6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Symfony/Component/Cache/Tests/Adapter/DoctrineDbalAdapterTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterfac
4848

4949
public function testConfigureSchemaDecoratedDbalDriver()
5050
{
51+
if (file_exists(self::$dbFile)) {
52+
@unlink(self::$dbFile);
53+
}
54+
5155
$connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile], $this->getDbalConfig());
5256
if (!interface_exists(Middleware::class)) {
5357
$this->markTestSkipped('doctrine/dbal v2 does not support custom drivers using middleware');
@@ -73,6 +77,10 @@ public function testConfigureSchemaDecoratedDbalDriver()
7377

7478
public function testConfigureSchema()
7579
{
80+
if (file_exists(self::$dbFile)) {
81+
@unlink(self::$dbFile);
82+
}
83+
7684
$connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile], $this->getDbalConfig());
7785
$schema = new Schema();
7886

@@ -83,6 +91,10 @@ public function testConfigureSchema()
8391

8492
public function testConfigureSchemaDifferentDbalConnection()
8593
{
94+
if (file_exists(self::$dbFile)) {
95+
@unlink(self::$dbFile);
96+
}
97+
8698
$otherConnection = $this->createConnectionMock();
8799
$schema = new Schema();
88100

@@ -93,6 +105,10 @@ public function testConfigureSchemaDifferentDbalConnection()
93105

94106
public function testConfigureSchemaTableExists()
95107
{
108+
if (file_exists(self::$dbFile)) {
109+
@unlink(self::$dbFile);
110+
}
111+
96112
$connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile], $this->getDbalConfig());
97113
$schema = new Schema();
98114
$schema->createTable('cache_items');

0 commit comments

Comments
 (0)
0