ArrayAdapterTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 42
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testGetArray() 0 4 1
A testGetNbResults() 0 4 1
A testGetResults() 0 6 1
A getResultsProvider() 0 7 1
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