Skip to content

Commit

Permalink
Added a failing test for DDC-2003
Browse files Browse the repository at this point in the history
  • Loading branch information
Josiah committed Aug 31, 2012
1 parent bc2476f commit 783c53d
Showing 1 changed file with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace Doctrine\Tests\ORM\Functional;

use Doctrine\Tests\Models\Generic\DateTimeModel;
use Doctrine\Common\Collections\Criteria;

require_once __DIR__ . '/../../TestInit.php';

/**
* @author Josiah <[email protected]>
*/
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));
}
}

0 comments on commit 783c53d

Please sign in to comment.