-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathNodeViewTest.php
More file actions
76 lines (62 loc) · 1.92 KB
/
Copy pathNodeViewTest.php
File metadata and controls
76 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
<?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;
/**
* test the query result node view $ 6.11.2.
*/
class NodeViewTest extends QueryBaseCase
{
public $nodeIterator;
public function setUp()
{
parent::setUp();
$this->nodeIterator = $this->query->execute()->getNodes();
}
public function testIterator()
{
$count = 0;
foreach ($this->nodeIterator as $node) {
$this->assertInstanceOf('PHPCR\NodeInterface', $node); // Test if the return element is an istance of node
$count++;
}
$this->assertEquals(5, $count, 'wrong number of elements in iterator');
}
public function testSeekable()
{
$seekPosition = 2;
$nodes = array();
$i = 0;
foreach ($this->nodeIterator as $path => $node) {
if ($i++ == $seekPosition) {
$seekNode = $node;
$seekKey = $path;
}
}
// note that in php 5.3.3, the array iterator gets the seek wrong and wants a string position instead of a number. according to the doc, we test for the correct behaviour here.
$this->nodeIterator->seek($seekPosition);
$this->assertEquals($seekKey, $this->nodeIterator->key());
$this->assertEquals($seekNode, $this->nodeIterator->current());
}
/**
* @expectedException \OutOfBoundsException
*/
public function testSeekableOutOfBounds()
{
$this->nodeIterator->seek(30);
}
public function testCountable()
{
$nodes = array();
foreach ($this->nodeIterator as $node) {
$nodes[] = $node;
}
$this->assertEquals(count($nodes), $this->nodeIterator->count());
}
}