Skip to content

Commit

Permalink
Rework the usage of the deprecated at() matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Aug 7, 2020
1 parent 568bf0c commit 7084d17
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 44 deletions.
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private function createConnection(DriverConnection $driverConnection, string $ex
$logger->expects($this->once())
->method('startQuery')
->with($this->equalTo($expectedSQL), $this->equalTo([]));
$logger->expects($this->at(1))
$logger->expects($this->once())
->method('stopQuery');

$connection = new Connection([], $driver);
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/DBAL/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function testConnectDispatchEvent(): void
$eventManager->addEventListener([Events::postConnect], $listenerMock);

$driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->at(0))
$driverMock->expects($this->once())
->method('connect');

$conn = new Connection([], $driverMock, new Configuration(), $eventManager);
Expand Down
24 changes: 6 additions & 18 deletions tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1174,29 +1174,17 @@ public function testComparesNamespaces(): void
->method('getNamespaces')
->will($this->returnValue(['foo', 'bar']));

$fromSchema->expects($this->at(0))
->method('hasNamespace')
->with('bar')
->will($this->returnValue(true));

$fromSchema->expects($this->at(1))
->method('hasNamespace')
->with('baz')
->will($this->returnValue(false));
$fromSchema->method('hasNamespace')
->withConsecutive(['bar'], ['baz'])
->willReturnOnConsecutiveCalls(true, false);

$toSchema->expects($this->once())
->method('getNamespaces')
->will($this->returnValue(['bar', 'baz']));

$toSchema->expects($this->at(1))
->method('hasNamespace')
->with('foo')
->will($this->returnValue(false));

$toSchema->expects($this->at(2))
->method('hasNamespace')
->with('bar')
->will($this->returnValue(true));
$toSchema->method('hasNamespace')
->withConsecutive(['foo'], ['bar'])
->willReturnOnConsecutiveCalls(false, true);

$expected = new SchemaDiff();
$expected->fromSchema = $fromSchema;
Expand Down
38 changes: 14 additions & 24 deletions tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public function testVisitsVisitor(): void
[$schema->getSequence('war')]
);

self::assertNull($schema->visit($visitor));
$schema->visit($visitor);
}

public function testVisitsNamespaceVisitor(): void
Expand All @@ -392,34 +392,24 @@ public function testVisitsNamespaceVisitor(): void
->method('acceptSchema')
->with($schema);

$visitor->expects($this->at(1))
$visitor->expects($this->exactly(3))
->method('acceptNamespace')
->with('foo');
->withConsecutive(['foo'], ['bar'], ['bla']);

$visitor->expects($this->at(2))
->method('acceptNamespace')
->with('bar');

$visitor->expects($this->at(3))
->method('acceptNamespace')
->with('bla');

$visitor->expects($this->at(4))
$visitor->expects($this->exactly(2))
->method('acceptTable')
->with($schema->getTable('baz'));

$visitor->expects($this->at(5))
->method('acceptTable')
->with($schema->getTable('bla.bloo'));

$visitor->expects($this->at(6))
->method('acceptSequence')
->with($schema->getSequence('moo'));
->withConsecutive(
[$schema->getTable('baz')],
[$schema->getTable('bla.bloo')]
);

$visitor->expects($this->at(7))
$visitor->expects($this->exactly(2))
->method('acceptSequence')
->with($schema->getSequence('war'));
->withConsecutive(
[$schema->getSequence('moo')],
[$schema->getSequence('war')]
);

self::assertNull($schema->visit($visitor));
$schema->visit($visitor);
}
}

0 comments on commit 7084d17

Please sign in to comment.