Skip to content

Commit f27fe84

Browse files
chore: Replace deprecated dbal calls
1 parent 2bb54d5 commit f27fe84

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

src/Command/SchemaExistsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5555

5656
protected function hasTables(): bool
5757
{
58-
$tables = $this->connection->createSchemaManager()->listTables();
58+
$tables = $this->connection->createSchemaManager()->introspectTables();
5959

6060
return count($tables) > 0;
6161
}

src/Command/WaitForDatabaseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5858
protected function isDatabaseReady(OutputInterface $output, int $retrySeconds): bool
5959
{
6060
try {
61-
$this->connection->createSchemaManager()->listTables();
61+
$this->connection->createSchemaManager()->introspectTables();
6262
} catch (Throwable $exception) {
6363
$this->handleError($output, $exception, $retrySeconds);
6464

tests/Command/SchemaExistsCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function testTablesPresent(): void
1919
{
2020
$schemaManager = $this->createMock(AbstractSchemaManager::class);
2121
$schemaManager->expects($this->once())
22-
->method('listTables')
22+
->method('introspectTables')
2323
->willReturn(['x']);
2424

2525
$connection = $this->createMock(Connection::class);
@@ -39,7 +39,7 @@ public function testTablesMissing(): void
3939
{
4040
$schemaManager = $this->createMock(AbstractSchemaManager::class);
4141
$schemaManager->expects($this->once())
42-
->method('listTables')
42+
->method('introspectTables')
4343
->willReturn([]);
4444

4545
$connection = $this->createMock(Connection::class);

tests/Command/WaitForDatabaseCommandTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testDatabaseImmediatlyAvailable(): void
3030
{
3131
$schemaManager = $this->createMock(AbstractSchemaManager::class);
3232
$schemaManager->expects($this->once())
33-
->method('listTables')
33+
->method('introspectTables')
3434
->willReturn(['x']);
3535

3636
$connection = $this->createMock(Connection::class);
@@ -48,13 +48,19 @@ public function testDatabaseImmediatlyAvailable(): void
4848

4949
public function testDatabaseAvailableAfterRetry(): void
5050
{
51+
$callCount = 0;
5152
$schemaManager = $this->createMock(AbstractSchemaManager::class);
5253
$schemaManager->expects($this->any())
53-
->method('listTables')
54-
->will($this->onConsecutiveCalls(
55-
$this->throwException(new RuntimeException('Connection failed.')),
56-
$this->returnValue(['x']),
57-
));
54+
->method('introspectTables')
55+
->willReturnCallback(static function () use (&$callCount) {
56+
++$callCount;
57+
if ($callCount === 1) {
58+
// phpcs:ignore Brainbits.Exception.GlobalException.GlobalException
59+
throw new RuntimeException('Connection failed.');
60+
}
61+
62+
return ['x'];
63+
});
5864

5965
$connection = $this->createMock(Connection::class);
6066
$connection->expects($this->any())
@@ -69,20 +75,15 @@ public function testDatabaseAvailableAfterRetry(): void
6975
$this->assertSame(0, $result);
7076

7177
preg_match_all('/Connection failed/', $tester->getDisplay(), $match);
72-
$this->assertCount(1, $match[0] ?? []);
78+
$this->assertCount(1, $match[0]);
7379
}
7480

7581
public function testDatabaseFailAfterRetry(): void
7682
{
7783
$schemaManager = $this->createMock(AbstractSchemaManager::class);
7884
$schemaManager->expects($this->any())
79-
->method('listTables')
80-
->will($this->onConsecutiveCalls(
81-
$this->throwException(new RuntimeException('Connection failed.')),
82-
$this->throwException(new RuntimeException('Connection failed.')),
83-
$this->throwException(new RuntimeException('Connection failed.')),
84-
$this->throwException(new RuntimeException('Connection failed.')),
85-
));
85+
->method('introspectTables')
86+
->willThrowException(new RuntimeException('Connection failed.'));
8687

8788
$connection = $this->createMock(Connection::class);
8889
$connection->expects($this->any())
@@ -97,6 +98,6 @@ public function testDatabaseFailAfterRetry(): void
9798
$this->assertSame(200, $result);
9899

99100
preg_match_all('/Connection failed/', $tester->getDisplay(), $match);
100-
$this->assertCount(4, $match[0] ?? []);
101+
$this->assertCount(4, $match[0]);
101102
}
102103
}

0 commit comments

Comments
 (0)