ResultTest   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 72
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
B setup() 0 32 1
A testGetTotalRows() 0 4 1
A testGetOffset() 0 4 1
A testGetFirstRow() 0 4 1
A testGetLastRow() 0 4 1
A testGetRows() 0 4 1
A testGetIterator() 0 6 1
A testCount() 0 4 1
1
<?php
2
3
namespace CouchDB\Tests\DesignDocument;
4
5
use CouchDB\DesignDocument\Result;
6
7
/**
8
 * @author Markus Bachmann <[email protected]>
9
 */
10
class ResultTest extends \PHPUnit_Framework_TestCase
11
{
12
    protected function setup()
13
    {
14
        $this->resultData = [
15
            'total_rows' => 51,
16
            'offset'     => 0,
17
            'rows'       => [
18
                [
19
                    'id'     => '64ACF01B05F53ACFEC48C062A5D01D89',
20
                    'key'    => null,
21
                    'value'  => [
22
                        'foo' => 'bar',
23
                    ],
24
                ],
25
                [
26
                    'id'    => '5D01D8964ACF01B05F53ACFEC48C062A',
27
                    'key'   => null,
28
                    'value' => [
29
                        'foo' => 'bar',
30
                    ],
31
                ],
32
                [
33
                    'id'    => 'EC48C062A5D01D8964ACF01B05F53ACF',
34
                    'key'   => null,
35
                    'value' => [
36
                        'foo' => 'bar',
37
                    ],
38
                ],
39
            ],
40
        ];
41
42
        $this->result = new Result($this->resultData);
43
    }
44
45
    public function testGetTotalRows()
46
    {
47
        $this->assertEquals(51, $this->result->getTotalRows());
48
    }
49
50
    public function testGetOffset()
51
    {
52
        $this->assertEquals(0, $this->result->getOffset());
53
    }
54
55
    public function testGetFirstRow()
56
    {
57
        $this->assertEquals($this->resultData['rows'][0], $this->result->getFirstRow());
58
    }
59
60
    public function testGetLastRow()
61
    {
62
        $this->assertEquals($this->resultData['rows'][2], $this->result->getLastRow());
63
    }
64
65
    public function testGetRows()
66
    {
67
        $this->assertEquals($this->resultData['rows'], $this->result->getRows());
68
    }
69
70
    public function testGetIterator()
71
    {
72
        $iterator = $this->result->getIterator();
73
        $this->assertInstanceOf('Iterator', $iterator);
74
        $this->assertEquals($this->resultData['rows'], $iterator->getArrayCopy());
75
    }
76
77
    public function testCount()
78
    {
79
        $this->assertCount(3, $this->result);
80
    }
81
}
82