From 4375bd3b5552c58b154f4a312907805834934982 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 13 Jun 2020 22:37:23 -0700 Subject: [PATCH] Forward compatibility with PHPUnit 9.3 --- .../DBAL/Driver/OCI8/OCI8StatementTest.php | 2 +- .../Doctrine/Tests/DBAL/Schema/SchemaTest.php | 37 +++++-------------- .../Visitor/DropSchemaSqlCollectorTest.php | 14 +++---- .../DBAL/Tools/Console/RunSqlCommandTest.php | 22 +++++------ 4 files changed, 27 insertions(+), 48 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index 6ab31682f37..77cb231f9a3 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -105,7 +105,7 @@ public static function executeDataProvider(): iterable public function testConvertNonTerminatedLiteral(string $sql, string $message): void { $this->expectException(OCI8Exception::class); - $this->expectExceptionMessageRegExp($message); + $this->expectExceptionMessageMatches($message); OCI8Statement::convertPositionalToNamedPlaceholders($sql); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php index cc665df5bd1..29a61744b96 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -378,27 +378,19 @@ public function testVisitsVisitor(): void ->method('acceptSchema') ->with($schema); - $visitor->expects($this->at(1)) + $visitor->expects(self::exactly(2)) ->method('acceptTable') - ->with($schema->getTable('baz')); + ->withConsecutive( + [$schema->getTable('baz')], + [$schema->getTable('bla.bloo')] + ); - $visitor->expects($this->at(2)) - ->method('acceptTable') - ->with($schema->getTable('bla.bloo')); - - $visitor->expects($this->exactly(2)) - ->method('acceptTable'); - - $visitor->expects($this->at(3)) + $visitor->expects(self::exactly(2)) ->method('acceptSequence') - ->with($schema->getSequence('moo')); - - $visitor->expects($this->at(4)) - ->method('acceptSequence') - ->with($schema->getSequence('war')); - - $visitor->expects($this->exactly(2)) - ->method('acceptSequence'); + ->withConsecutive( + [$schema->getSequence('moo')], + [$schema->getSequence('war')] + ); self::assertNull($schema->visit($visitor)); } @@ -436,9 +428,6 @@ public function testVisitsNamespaceVisitor(): void ->method('acceptNamespace') ->with('bla'); - $visitor->expects($this->exactly(3)) - ->method('acceptNamespace'); - $visitor->expects($this->at(4)) ->method('acceptTable') ->with($schema->getTable('baz')); @@ -447,9 +436,6 @@ public function testVisitsNamespaceVisitor(): void ->method('acceptTable') ->with($schema->getTable('bla.bloo')); - $visitor->expects($this->exactly(2)) - ->method('acceptTable'); - $visitor->expects($this->at(6)) ->method('acceptSequence') ->with($schema->getSequence('moo')); @@ -458,9 +444,6 @@ public function testVisitsNamespaceVisitor(): void ->method('acceptSequence') ->with($schema->getSequence('war')); - $visitor->expects($this->exactly(2)) - ->method('acceptSequence'); - self::assertNull($schema->visit($visitor)); } } diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php index bd663dc93e6..1adde346002 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php @@ -28,16 +28,12 @@ public function testGetQueriesUsesAcceptedForeignKeys(): void $collector = new DropSchemaSqlCollector($platform); - $platform->expects($this->exactly(2)) - ->method('getDropForeignKeySQL'); - - $platform->expects($this->at(0)) - ->method('getDropForeignKeySQL') - ->with($keyConstraintOne, $tableOne); - - $platform->expects($this->at(1)) + $platform->expects(self::exactly(2)) ->method('getDropForeignKeySQL') - ->with($keyConstraintTwo, $tableTwo); + ->withConsecutive( + [$keyConstraintOne, $tableOne], + [$keyConstraintTwo, $tableTwo] + ); $collector->acceptForeignKey($tableOne, $keyConstraintOne); $collector->acceptForeignKey($tableTwo, $keyConstraintTwo); diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index ef524e8ceca..15c8728dd87 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -31,10 +31,6 @@ protected function setUp(): void $this->commandTester = new CommandTester($this->command); $this->connectionMock = $this->createMock(Connection::class); - $this->connectionMock->method('fetchAllAssociative') - ->willReturn([[1]]); - $this->connectionMock->method('executeUpdate') - ->willReturn(42); $helperSet = ConsoleRunner::createHelperSet($this->connectionMock); $this->command->setHelperSet($helperSet); @@ -97,21 +93,25 @@ public function testUpdateStatementsPrintsAffectedLines(): void private function expectConnectionExecuteUpdate(): void { $this->connectionMock - ->expects($this->exactly(1)) - ->method('executeUpdate'); + ->expects($this->once()) + ->method('executeUpdate') + ->willReturn(42); + $this->connectionMock - ->expects($this->exactly(0)) + ->expects($this->never()) ->method('fetchAllAssociative'); } private function expectConnectionFetchAllAssociative(): void { $this->connectionMock - ->expects($this->exactly(0)) - ->method('executeUpdate'); + ->expects($this->once()) + ->method('fetchAllAssociative') + ->willReturn([[1]]); + $this->connectionMock - ->expects($this->exactly(1)) - ->method('fetchAllAssociative'); + ->expects($this->never()) + ->method('executeUpdate'); } public function testStatementsWithFetchResultPrintsResult(): void