[tests] Replace deprecated TestCase::at().

The "at" matcher will be removed in PHPUnit 10 but it is not a bad thing
after all because it was cumbersome and error-prone.

Took the opportunity to improve some tests while converting them.
This commit is contained in:
Daniele Alessandri
2020-08-29 00:20:04 +02:00
parent c6f2ce4b83
commit 6d6c970ae2
16 changed files with 760 additions and 693 deletions
@@ -46,15 +46,16 @@ class ReplicationTest extends PredisTestCase
/** @var OptionsInterface|MockObject */
$options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock();
$options
->expects($this->at(0))
->expects($this->exactly(2))
->method('__get')
->with('autodiscovery')
->willReturn(true);
$options
->expects($this->at(1))
->method('__get')
->with('connections')
->willReturn($connectionFactory);
->withConsecutive(
array('autodiscovery'),
array('connections')
)
->willReturnOnConsecutiveCalls(
true,
$connectionFactory
);
$this->assertInstanceOf('Closure', $initializer = $option->getDefault($options));
$this->assertInstanceOf('Predis\Connection\Replication\MasterSlaveReplication', $connection = $initializer($options));
@@ -142,17 +143,16 @@ class ReplicationTest extends PredisTestCase
/** @var OptionsInterface|MockObject */
$options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock();
$options
->expects($this->at(0))
->expects($this->exactly(2))
->method('__get')
->with('service')
->willReturn('mymaster');
$options
->expects($this->at(1))
->method('__get')
->with('connections')
->will($this->returnValue(
->withConsecutive(
array('service'),
array('connections')
)
->willReturnOnConsecutiveCalls(
'mymaster',
$this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock()
));
);
$parameters = array(
$this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(),