ArrayAdapterTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Pagerfanta\Tests\Adapter;
4
5
use Pagerfanta\Adapter\ArrayAdapter;
6
use PHPUnit\Framework\TestCase;
7
8
class ArrayAdapterTest extends TestCase
9
{
10
    private $array;
11
    /**
12
     * @var ArrayAdapter
13
     */
14
    private $adapter;
15
16
    protected function setUp()
17
    {
18
        $this->array = range(1, 100);
19
        $this->adapter = new ArrayAdapter($this->array);
20
    }
21
22
    public function testGetArray()
23
    {
24
        $this->assertSame($this->array, $this->adapter->getArray());
25
    }
26
27
    public function testGetNbResults()
28
    {
29
        $this->assertSame(100, $this->adapter->getNbResults());
30
    }
31
32
    /**
33
     * @dataProvider getResultsProvider
34
     */
35
    public function testGetResults($offset, $length)
36
    {
37
        $expected = array_slice($this->array, $offset, $length);
38
39
        $this->assertSame($expected, $this->adapter->getSlice($offset, $length));
40
    }
41
42
    public function getResultsProvider()
43
    {
44
        return array(
45
            array(2, 10),
46
            array(3, 2),
47
        );
48
    }
49
}
50