Skip to content

provide a separate test for ordering with and without missing properties #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fixtures/general/base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
<sv:value>2009-04-27T13:01:07.472+02:00</sv:value>
</sv:property>

<sv:property sv:name="foo" sv:type="String">
<sv:value>bar2</sv:value>
</sv:property>

<sv:property sv:name="jcr:mimeType" sv:type="String">
<sv:value>text/plain</sv:value>
</sv:property>
Expand Down
28 changes: 26 additions & 2 deletions tests/06_Query/QuerySql2OperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('
Expand All @@ -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()
Expand Down