From eda42ed5b3cfb0b538d1352423e9e59d2d909393 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Tue, 25 Feb 2014 10:57:10 +0100 Subject: [PATCH] test join on issamenode --- fixtures/general/base.xml | 3 ++ tests/06_Query/QuerySql2OperationsTest.php | 50 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/fixtures/general/base.xml b/fixtures/general/base.xml index 9da9e31e..7beddb5e 100644 --- a/fixtures/general/base.xml +++ b/fixtures/general/base.xml @@ -239,6 +239,9 @@ nt:unstructured + + mix:referenceable + bar diff --git a/tests/06_Query/QuerySql2OperationsTest.php b/tests/06_Query/QuerySql2OperationsTest.php index 2c19be6c..9e625522 100644 --- a/tests/06_Query/QuerySql2OperationsTest.php +++ b/tests/06_Query/QuerySql2OperationsTest.php @@ -271,6 +271,56 @@ public function testQueryJoinChildnode() $this->assertEquals(array(999), $vals); } + public function testQueryJoinSamenode() + { + /** @var $query QueryInterface */ + $query = $this->sharedFixture['qm']->createQuery(' + SELECT [nt:unstructured].longNumber + FROM [nt:unstructured] + INNER JOIN [nt:file] + ON ISSAMENODE([nt:unstructured], [nt:file], "jcr:content") + WHERE [nt:unstructured].longNumber = 999 + AND ISDESCENDANTNODE([nt:unstructured], [/tests_general_base]) + ', + QueryInterface::JCR_SQL2 + ); + + $this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query); + $result = $query->execute(); + $this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result); + $vals = array(); + + foreach ($result->getRows() as $row) { + $vals[] = $row->getValue('nt:file.path'); + } + $this->assertEquals(array(999), $vals); + } + + public function testQueryJoinSamenodeIdent() + { + /** @var $query QueryInterface */ + $query = $this->sharedFixture['qm']->createQuery(' + SELECT [nt:unstructured].longNumber + FROM [nt:unstructured] + INNER JOIN [mix:referenceable] + ON ISSAMENODE([mix:referenceable], [nt:unstructured]) + WHERE [nt:unstructured].longNumber = 999 + AND ISDESCENDANTNODE([nt:unstructured], [/tests_general_base]) + ', + QueryInterface::JCR_SQL2 + ); + + $this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query); + $result = $query->execute(); + $this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result); + $vals = array(); + + foreach ($result->getRows() as $row) { + $vals[] = $row->getValue('nt:file.path'); + } + $this->assertEquals(array(999), $vals); + } + public function testQueryOrder() { /** @var $query QueryInterface */