mirror of
https://github.com/predis/predis.git
synced 2026-10-08 21:06:44 +00:00
[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:
@@ -173,17 +173,14 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->exactly(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array())
|
||||
->willReturn(
|
||||
array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0))
|
||||
);
|
||||
$client
|
||||
->expects($this->at(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 2, array())
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array()),
|
||||
array('key:zset', 2, array())
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0)),
|
||||
array(0, array('member:3rd' => 3.0))
|
||||
);
|
||||
|
||||
@@ -223,17 +220,14 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->exactly(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array())
|
||||
->willReturn(
|
||||
array(4, array())
|
||||
);
|
||||
$client
|
||||
->expects($this->at(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 4, array())
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array()),
|
||||
array('key:zset', 4, array())
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(4, array()),
|
||||
array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0))
|
||||
);
|
||||
|
||||
@@ -268,24 +262,16 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->exactly(3))
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array())
|
||||
->willReturn(
|
||||
array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0))
|
||||
);
|
||||
$client
|
||||
->expects($this->at(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 2, array())
|
||||
->willReturn(
|
||||
array(5, array())
|
||||
);
|
||||
$client
|
||||
->expects($this->at(3))
|
||||
->method('zscan')
|
||||
->with('key:zset', 5, array())
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array()),
|
||||
array('key:zset', 2, array()),
|
||||
array('key:zset', 5, array())
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0)),
|
||||
array(5, array()),
|
||||
array(0, array('member:3rd' => 3.0))
|
||||
);
|
||||
|
||||
@@ -325,11 +311,15 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->exactly(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array('MATCH' => 'member:*'))
|
||||
->willReturn(
|
||||
array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0))
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array('MATCH' => 'member:*')),
|
||||
array('key:zset', 2, array('MATCH' => 'member:*'))
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0)),
|
||||
array(0, array())
|
||||
);
|
||||
|
||||
$iterator = new SortedSetKey($client, 'key:zset', 'member:*');
|
||||
@@ -363,17 +353,14 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->exactly(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array('MATCH' => 'member:*'))
|
||||
->willReturn(
|
||||
array(1, array('member:1st' => 1.0))
|
||||
);
|
||||
$client
|
||||
->expects($this->at(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 1, array('MATCH' => 'member:*'))
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array('MATCH' => 'member:*')),
|
||||
array('key:zset', 1, array('MATCH' => 'member:*'))
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(1, array('member:1st' => 1.0)),
|
||||
array(0, array('member:2nd' => 2.0))
|
||||
);
|
||||
|
||||
@@ -408,10 +395,12 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->once())
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array('COUNT' => 2))
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array('COUNT' => 2))
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0))
|
||||
);
|
||||
|
||||
@@ -446,17 +435,14 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->exactly(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array('COUNT' => 1))
|
||||
->willReturn(
|
||||
array(1, array('member:1st' => 1.0))
|
||||
);
|
||||
$client
|
||||
->expects($this->at(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 1, array('COUNT' => 1))
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array('COUNT' => 1)),
|
||||
array('key:zset', 1, array('COUNT' => 1))
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(1, array('member:1st' => 1.0)),
|
||||
array(0, array('member:2nd' => 2.0))
|
||||
);
|
||||
|
||||
@@ -491,10 +477,12 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->once())
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 2))
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 2))
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0))
|
||||
);
|
||||
|
||||
@@ -529,17 +517,14 @@ class SortedSetKeyTest extends PredisTestCase
|
||||
->method('getCommandFactory')
|
||||
->willReturn($this->getCommandFactory());
|
||||
$client
|
||||
->expects($this->at(1))
|
||||
->expects($this->exactly(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 1))
|
||||
->willReturn(
|
||||
array(1, array('member:1st' => 1.0))
|
||||
);
|
||||
$client
|
||||
->expects($this->at(2))
|
||||
->method('zscan')
|
||||
->with('key:zset', 1, array('MATCH' => 'member:*', 'COUNT' => 1))
|
||||
->willReturn(
|
||||
->withConsecutive(
|
||||
array('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 1)),
|
||||
array('key:zset', 1, array('MATCH' => 'member:*', 'COUNT' => 1))
|
||||
)
|
||||
->willReturnOnConsecutiveCalls(
|
||||
array(1, array('member:1st' => 1.0)),
|
||||
array(0, array('member:2nd' => 2.0))
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user