|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pagerfanta\Tests\Adapter; |
|
4
|
|
|
|
|
5
|
|
|
use Pagerfanta\Adapter\ArrayAdapter; |
|
6
|
|
|
use Pagerfanta\Adapter\ConcatenationAdapter; |
|
7
|
|
|
use Pagerfanta\Adapter\FixedAdapter; |
|
8
|
|
|
use Pagerfanta\Adapter\NullAdapter; |
|
9
|
|
|
|
|
10
|
|
|
class ConcatenationAdapterTest extends \PHPUnit_Framework_TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testConstructor() |
|
13
|
|
|
{ |
|
14
|
|
|
new ConcatenationAdapter(array( |
|
15
|
|
|
new ArrayAdapter(array()), |
|
16
|
|
|
new NullAdapter(), |
|
17
|
|
|
new FixedAdapter(0, array()) |
|
18
|
|
|
)); |
|
19
|
|
|
|
|
20
|
|
|
$this->setExpectedException('\Pagerfanta\Exception\InvalidArgumentException'); |
|
|
|
|
|
|
21
|
|
|
new ConcatenationAdapter(array( |
|
|
|
|
|
|
22
|
|
|
new ArrayAdapter(array()), |
|
23
|
|
|
'foo' |
|
24
|
|
|
)); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testGetNbResults() |
|
28
|
|
|
{ |
|
29
|
|
|
$adapter = new ConcatenationAdapter(array( |
|
30
|
|
|
new ArrayAdapter(array('foo', 'bar', 'baz')) |
|
31
|
|
|
)); |
|
32
|
|
|
$this->assertEquals(3, $adapter->getNbResults()); |
|
33
|
|
|
|
|
34
|
|
|
$adapter = new ConcatenationAdapter(array( |
|
35
|
|
|
new ArrayAdapter(array_fill(0, 4, 'foo')), |
|
36
|
|
|
new ArrayAdapter(array_fill(0, 6, 'bar')), |
|
37
|
|
|
new ArrayAdapter(array('baq')) |
|
38
|
|
|
)); |
|
39
|
|
|
$this->assertEquals(11, $adapter->getNbResults()); |
|
40
|
|
|
|
|
41
|
|
|
$adapter = new ConcatenationAdapter(array()); |
|
42
|
|
|
$this->assertEquals(0, $adapter->getNbResults()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testGetResults() |
|
46
|
|
|
{ |
|
47
|
|
|
$adapter = new ConcatenationAdapter(array( |
|
48
|
|
|
new ArrayAdapter(array(1, 2, 3, 4, 5, 6)), |
|
49
|
|
|
new ArrayAdapter(array(7, 8, 9, 10, 11, 12, 13, 14)), |
|
50
|
|
|
new ArrayAdapter(array(15, 16, 17)) |
|
51
|
|
|
)); |
|
52
|
|
|
$this->assertEquals(array(8, 9, 10), $adapter->getSlice(7, 3)); |
|
53
|
|
|
$this->assertEquals(array(5, 6, 7, 8), $adapter->getSlice(4, 4)); |
|
54
|
|
|
$this->assertEquals(array(6, 7, 8, 9, 10, 11, 12, 13, 14, 15), $adapter->getSlice(5, 10)); |
|
55
|
|
|
$this->assertEquals(array(16, 17), $adapter->getSlice(15, 5)); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.