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
|
|
|
|