From c01d8ef94a5d660afb7e531144fc14d23bf488fb Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Sun, 6 Oct 2013 19:08:38 +0200 Subject: [PATCH] provide a separate test for ordering with and without missing properties --- fixtures/general/base.xml | 4 ++++ tests/06_Query/QuerySql2OperationsTest.php | 28 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/fixtures/general/base.xml b/fixtures/general/base.xml index d3f35574..9da9e31e 100644 --- a/fixtures/general/base.xml +++ b/fixtures/general/base.xml @@ -100,6 +100,10 @@ 2009-04-27T13:01:07.472+02:00 + + bar2 + + text/plain diff --git a/tests/06_Query/QuerySql2OperationsTest.php b/tests/06_Query/QuerySql2OperationsTest.php index 833f9d5f..7b90991c 100644 --- a/tests/06_Query/QuerySql2OperationsTest.php +++ b/tests/06_Query/QuerySql2OperationsTest.php @@ -247,6 +247,30 @@ public function testQueryJoinReference() } public function testQueryOrder() + { + /** @var $query QueryInterface */ + $query = $this->sharedFixture['qm']->createQuery(' + SELECT data.foo + FROM [nt:unstructured] AS data + WHERE ISDESCENDANTNODE([/tests_general_base]) AND data.foo IS NOT NULL + ORDER BY data.foo + ', + 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('data.foo'); + } + + // rows that do not have that field are empty string. empty is before fields with values + $this->assertEquals(array('bar', 'bar2'), $vals); + } + + public function testQueryOrderWithMissingProperty() { /** @var $query QueryInterface */ $query = $this->sharedFixture['qm']->createQuery(' @@ -265,8 +289,8 @@ public function testQueryOrder() foreach ($result->getRows() as $row) { $vals[] = $row->getValue('data.zeronumber'); } - // rows that do not have that field are null. empty is before fields with values - $this->assertEquals(array(null, null, null, null, null, null, null, null, 0), $vals); + // rows that do not have that field are empty string. empty is before fields with values + $this->assertEquals(array('', '', '', '', '', '', '', '', 0), $vals); } public function testQueryMultiValuedProperty()