Skip to content

Commit 133f50d

Browse files
committed
Dbal Adapter Test Suite - close connectsions in teardown
1 parent 857646d commit 133f50d

4 files changed

Lines changed: 25 additions & 12 deletions

File tree

src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Context/DatabaseContext.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
use Doctrine\DBAL\Connection;
88
use Doctrine\DBAL\Schema\Table;
99

10-
final readonly class DatabaseContext
10+
final class DatabaseContext
1111
{
12+
private array $createdTables = [];
13+
1214
public function __construct(
13-
private Connection $connection,
14-
private InsertQueryCounter $insertQueryCounter,
15-
private SelectQueryCounter $selectQueryCounter,
15+
private readonly Connection $connection,
16+
private readonly InsertQueryCounter $insertQueryCounter,
17+
private readonly SelectQueryCounter $selectQueryCounter,
1618
) {
1719
}
1820

@@ -30,14 +32,15 @@ public function createTable(Table $table) : void
3032
}
3133

3234
$schemaManager->createTable($table);
35+
$this->createdTables[] = $table->getName();
3336
}
3437

3538
public function dropAllTables() : void
3639
{
3740
$schemaManager = $this->connection->createSchemaManager();
3841

39-
foreach ($schemaManager->listTables() as $table) {
40-
$schemaManager->dropTable($table->getName());
42+
foreach ($this->createdTables as $tableName) {
43+
$schemaManager->dropTable($tableName);
4144
}
4245
}
4346

src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/IntegrationTestCase.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ protected function setUp() : void
5555
protected function tearDown() : void
5656
{
5757
$this->pgsqlDatabaseContext->dropAllTables();
58+
$this->mysqlDatabaseContext->dropAllTables();
59+
$this->sqliteDatabaseContext->dropAllTables();
60+
61+
$this->pgsqlDatabaseContext->connection()->close();
62+
$this->mysqlDatabaseContext->connection()->close();
63+
$this->sqliteDatabaseContext->connection()->close();
5864
}
5965

6066
protected function mysqlConnectionParams() : array

src/core/etl/src/Flow/ETL/DataFrame.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ public function limit(?int $limit) : self
513513
*/
514514
public function load(Loader $loader) : self
515515
{
516+
if ($loader instanceof LoaderExtension) {
517+
$this->context = $loader->onAdded($this->context);
518+
}
519+
516520
$this->pipeline = $this->context->config->optimizer()->optimize($loader, $this->pipeline);
517521

518522
return $this;

tools/blackfire/composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)