diff --git a/fixtures/05_Reading/jackalopeFetchDepth.xml b/fixtures/05_Reading/jackalopeFetchDepth.xml new file mode 100644 index 00000000..e4edf2bf --- /dev/null +++ b/fixtures/05_Reading/jackalopeFetchDepth.xml @@ -0,0 +1,43 @@ + + + + nt:unstructured + + + + + nt:unstructured + + + + + nt:unstructured + + + + + nt:unstructured + + + + + nt:unstructured + + + + + nt:unstructured + + + + + + + + diff --git a/tests/05_Reading/JackalopeFetchDepthTest.php b/tests/05_Reading/JackalopeFetchDepthTest.php new file mode 100644 index 00000000..6376bc00 --- /dev/null +++ b/tests/05_Reading/JackalopeFetchDepthTest.php @@ -0,0 +1,70 @@ +renewSession(); + } + + public function testGetNodeWithFetchDepth() + { + if (!$this->session instanceof \Jackalope\Session) { + return; + } + + $node = $this->rootNode->getNode('tests_read_jackalope_fetch_depth'); + + $this->session->setSessionOption(\Jackalope\Session::OPTION_FETCH_DEPTH, 5); + $deepExample = $node->getNode('deepExample'); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + + $deepExample = $deepExample->getNode('deepExample'); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + + $deepExample = $deepExample->getNode('deepExample'); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + + $deepExample = $deepExample->getNode('deepExample'); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + } + + public function testGetNodesWithFetchDepth() + { + if (!$this->session instanceof \Jackalope\Session) { + return; + } + + $node = $this->rootNode->getNode('tests_read_jackalope_fetch_depth'); + + $this->session->setSessionOption(\Jackalope\Session::OPTION_FETCH_DEPTH, 5); + $deepExamples = $node->getNodes('deepExample'); + $deepExample = $deepExamples->current(); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + + $deepExamples = $node->getNodes('deepExample'); + $deepExample = $deepExamples->current(); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + + $deepExamples = $node->getNodes('deepExample'); + $deepExample = $deepExamples->current(); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + + $deepExamples = $node->getNodes('deepExample'); + $deepExample = $deepExamples->current(); + $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); + } +}