From 783c53d57c622b10a182a2db99dab322296b4556 Mon Sep 17 00:00:00 2001 From: Josiah Truasheim Date: Fri, 31 Aug 2012 17:52:46 +0700 Subject: [PATCH] Added a failing test for DDC-2003 --- .../EntityRepositoryCriteriaTest.php | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php new file mode 100644 index 000000000..3f37a2307 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryCriteriaTest.php @@ -0,0 +1,71 @@ + + */ +class EntityRepositoryCriteriaTest extends \Doctrine\Tests\OrmFunctionalTestCase +{ + protected function setUp() { + $this->useModelSet('generic'); + parent::setUp(); + } + + public function tearDown() + { + if ($this->_em) { + $this->_em->getConfiguration()->setEntityNamespaces(array()); + } + parent::tearDown(); + } + + public function loadFixture() + { + $today = new DateTimeModel(); + $today->datetime = + $today->date = + $today->time = + new \DateTime('today'); + $this->_em->persist($today); + + $tomorrow = new DateTimeModel(); + $tomorrow->datetime = + $tomorrow->date = + $tomorrow->time = + new \DateTime('tomorrow'); + $this->_em->persist($tomorrow); + + $yesterday = new DateTimeModel(); + $yesterday->datetime = + $yesterday->date = + $yesterday->time = + new \DateTime('yesterday'); + $this->_em->persist($yesterday); + + $this->_em->flush(); + + unset($today); + unset($tomorrow); + unset($yesterday); + + $this->_em->clear(); + } + + public function testLteDateComparison() + { + $this->loadFixture(); + + $repository = $this->_em->getRepository('Doctrine\Tests\Models\Generic\DateTimeModel'); + $dates = $repository->matching(new Criteria( + Criteria::expr()->lte('datetime', new \DateTime('today')) + )); + + $this->assertEquals(2, count($dates)); + } +}