Skip to content

Commit 4e1a4c3

Browse files
committed
adjust to jcr refactorings: getNodes type filter, event primary and mixin node type
1 parent d9088ed commit 4e1a4c3

File tree

3 files changed

+158
-79
lines changed

3 files changed

+158
-79
lines changed

fixtures/12_Observation/manager.xml

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,47 @@
66
xmlns:jcr="http://www.jcp.org/jcr/1.0"
77
xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
88
sv:name="tests_observation_manager">
9-
<sv:property sv:name="jcr:primaryType" sv:type="Name">
10-
<sv:value>nt:unstructured</sv:value>
11-
</sv:property>
12-
<sv:property sv:name="jcr:created" sv:type="Date">
13-
<sv:value>2013-04-27T13:00:54.082+02:00</sv:value>
14-
</sv:property>
15-
<sv:node sv:name="testGetUnfilteredEventJournal">
169
<sv:property sv:name="jcr:primaryType" sv:type="Name">
17-
<sv:value>nt:unstructured</sv:value>
10+
<sv:value>nt:unstructured</sv:value>
1811
</sv:property>
19-
</sv:node>
20-
<sv:node sv:name="testFilteredEventJournal">
21-
<sv:property sv:name="jcr:primaryType" sv:type="Name">
22-
<sv:value>nt:unstructured</sv:value>
23-
</sv:property>
24-
</sv:node>
25-
<sv:node sv:name="testFilteredEventJournalUuid">
26-
<sv:property sv:name="jcr:primaryType" sv:type="Name">
27-
<sv:value>nt:unstructured</sv:value>
28-
</sv:property>
29-
</sv:node>
30-
<sv:node sv:name="testFilteredEventJournalNodeType">
31-
<sv:property sv:name="jcr:primaryType" sv:type="Name">
32-
<sv:value>nt:unstructured</sv:value>
33-
</sv:property>
34-
</sv:node>
35-
<sv:node sv:name="testUserData">
36-
<sv:property sv:name="jcr:primaryType" sv:type="Name">
37-
<sv:value>nt:unstructured</sv:value>
12+
<sv:property sv:name="jcr:created" sv:type="Date">
13+
<sv:value>2013-04-27T13:00:54.082+02:00</sv:value>
3814
</sv:property>
39-
</sv:node>
15+
<sv:node sv:name="testGetUnfilteredEventJournal">
16+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
17+
<sv:value>nt:unstructured</sv:value>
18+
</sv:property>
19+
</sv:node>
20+
<sv:node sv:name="testFilteredEventJournal">
21+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
22+
<sv:value>nt:unstructured</sv:value>
23+
</sv:property>
24+
</sv:node>
25+
<sv:node sv:name="testFilteredEventJournalUuid">
26+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
27+
<sv:value>nt:unstructured</sv:value>
28+
</sv:property>
29+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
30+
<sv:value>mix:referenceable</sv:value>
31+
</sv:property>
32+
<sv:property sv:name="jcr:uuid" sv:type="String">
33+
<sv:value>842e61c0-09ab-42a9-4444-308ccc90e6f4</sv:value>
34+
</sv:property>
35+
</sv:node>
36+
<sv:node sv:name="testFilteredEventJournalNodeType">
37+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
38+
<sv:value>nt:unstructured</sv:value>
39+
</sv:property>
40+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
41+
<sv:value>mix:referenceable</sv:value>
42+
</sv:property>
43+
<sv:property sv:name="jcr:uuid" sv:type="String">
44+
<sv:value>842e61c0-09ab-42a9-3333-308ccc90e6f4</sv:value>
45+
</sv:property>
46+
</sv:node>
47+
<sv:node sv:name="testUserData">
48+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
49+
<sv:value>nt:unstructured</sv:value>
50+
</sv:property>
51+
</sv:node>
4052
</sv:node>

tests/05_Reading/NodeReadMethodsTest.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,15 @@ public function testGetNodeRepositoryException()
149149

150150
public function testGetNodes()
151151
{
152-
$node1 = $this->rootNode->getNode('tests_general_base');
153-
$iterator = $this->rootNode->getNodes();
152+
$parent = $this->rootNode->getNode('tests_general_base');
153+
$iterator = $parent->getNodes();
154154
$this->assertInstanceOf('Iterator', $iterator);
155+
$this->assertInstanceOf('Countable', $iterator);
156+
157+
$this->assertCount(8, $iterator);
158+
foreach($iterator as $node) {
159+
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
160+
}
155161
}
156162

157163
/**
@@ -175,19 +181,44 @@ public function testGetNodesPattern()
175181
$this->assertNotContains('index.txt', $nodes);
176182
}
177183

178-
public function testGetNodesPatternAdvanced()
184+
public function testGetNodesTypeFilter()
179185
{
180186
$this->node = $this->rootNode->getNode('tests_general_base');
181-
$iterator = $this->node->getNodes("test:* | idExample");
187+
$iterator = $this->node->getNodes(null, 'nt:file');
182188
$nodes = array();
183189
foreach ($iterator as $n) {
184190
$this->assertInstanceOf('PHPCR\NodeInterface', $n);
185191
/** @var $n \PHPCR\NodeInterface */
186192
array_push($nodes, $n->getName());
187193
}
194+
$this->assertContains('index.txt', $nodes);
188195
$this->assertContains('idExample', $nodes);
189-
$this->assertContains('test:namespacedNode', $nodes);
196+
$this->assertNotContains('test:namespacedNode', $nodes);
197+
$this->assertNotContains('emptyExample', $nodes);
198+
$this->assertNotContains('multiValueProperty', $nodes);
199+
$this->assertContains('numberPropertyNode', $nodes);
200+
$this->assertContains('NumberPropertyNodeToCompare1', $nodes);
201+
$this->assertContains('NumberPropertyNodeToCompare2', $nodes);
202+
}
203+
204+
public function testGetNodesTypeFilterList()
205+
{
206+
$this->node = $this->rootNode->getNode('tests_general_base');
207+
$iterator = $this->node->getNodes("id*", array('nt:file', 'nt:folder'));
208+
$nodes = array();
209+
foreach ($iterator as $n) {
210+
$this->assertInstanceOf('PHPCR\NodeInterface', $n);
211+
/** @var $n \PHPCR\NodeInterface */
212+
array_push($nodes, $n->getName());
213+
}
190214
$this->assertNotContains('index.txt', $nodes);
215+
$this->assertContains('idExample', $nodes);
216+
$this->assertNotContains('test:namespacedNode', $nodes);
217+
$this->assertNotContains('emptyExample', $nodes);
218+
$this->assertNotContains('multiValueProperty', $nodes);
219+
$this->assertNotContains('numberPropertyNode', $nodes);
220+
$this->assertNotContains('NumberPropertyNodeToCompare1', $nodes);
221+
$this->assertNotContains('NumberPropertyNodeToCompare2', $nodes);
191222
}
192223

193224
public function testGetNodesNameGlobs()

0 commit comments

Comments
 (0)