-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathRowIteratorTest.php
More file actions
79 lines (62 loc) · 1.92 KB
/
Copy pathRowIteratorTest.php
File metadata and controls
79 lines (62 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/*
* This file is part of the PHPCR API Tests package
*
* Copyright (c) 2015 Liip and others
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPCR\Tests\Query;
/**
* $ 6.11.1 Row View - Iterator part.
*/
class RowIteratorTest extends QueryBaseCase
{
public $rowIterator;
public function setUp()
{
parent::setUp();
$this->rowIterator = $this->query->execute()->getRows();
$this->assertCount(5, $this->rowIterator);
}
public function testIterator()
{
$count = 0;
foreach ($this->rowIterator as $key => $row) {
$this->assertInstanceOf('PHPCR\Query\RowInterface', $row); // Test if the return element is an istance of row
$this->assertInstanceOf('PHPCR\NodeInterface', $row->getNode()); //Test if we can get the node of a certain row
$this->assertCount(3, $row->getValues()); // test if we can get all the values of a row
foreach ($row as $key => $value) { // Test if we can iterate over the columns inside a row
$count++;
}
}
$this->assertEquals(15, $count);
}
public function testSeekable()
{
$position = 2;
$rows = array();
foreach ($this->rowIterator as $row) {
$rows[] = $row;
}
$this->rowIterator->seek($position);
$this->assertEquals($rows[$position], $this->rowIterator->current());
}
/**
* @expectedException \OutOfBoundsException
*/
public function testSeekableOutOfBounds()
{
$position = -1;
$this->rowIterator->seek($position);
}
public function testCountable()
{
$rows = array();
foreach ($this->rowIterator as $row) {
$rows[] = $row;
}
$this->assertEquals(count($rows), $this->rowIterator->count());
}
}