Skip to content

Commit 2b71365

Browse files
committed
testing date in queries
1 parent 11f6d7a commit 2b71365

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/Query/QuerySql2OperationsTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace PHPCR\Tests\Query;
1313

1414
use PHPCR\Query\QueryInterface;
15+
use PHPCR\Query\RowInterface;
1516

1617
/**
1718
* Run non-trivial queries to try out where, the join features and such.
@@ -46,6 +47,26 @@ public function testQueryField()
4647
$this->assertEquals(array('bar'), $vals);
4748
}
4849

50+
public function testQueryFieldDate()
51+
{
52+
/** @var $query QueryInterface */
53+
$query = $this->sharedFixture['qm']->createQuery("
54+
SELECT *
55+
FROM [nt:base]
56+
WHERE [mydateprop] <= CAST('2011-04-27T13:01:07.472+02:00' AS DATE)
57+
AND [mydateprop] >= CAST('2011-04-01T13:01:07.472+02:00' AS DATE)
58+
AND (ISSAMENODE([/tests_general_base]) OR ISDESCENDANTNODE([/tests_general_base]))
59+
",
60+
QueryInterface::JCR_SQL2
61+
);
62+
63+
$result = $query->execute();
64+
$this->assertCount(1, $result->getRows());
65+
/** @var RowInterface $row */
66+
$row = $result->getRows()->current();
67+
$this->assertEquals('/tests_general_base/index.txt/jcr:content', $row->getPath());
68+
}
69+
4970
public function testQueryFieldSomeNull()
5071
{
5172
/** @var $query QueryInterface */

0 commit comments

Comments
 (0)