From cc06508bd448c19199b0f173ea45d2d54653ae93 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 4 Apr 2012 18:25:42 +0200 Subject: [PATCH] Added test coverage for repository functions when using filters --- .../Tests/ORM/Functional/SQLFilterTest.php | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php index 31ebb2d46..d55891d91 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php @@ -328,6 +328,80 @@ class SQLFilterTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertNotEquals($firstSQLQuery, $query->getSQL()); } + public function testRepositoryFind() + { + $this->loadFixtureData(); + + $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId)); + $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId2)); + + $this->useCMSGroupPrefixFilter(); + $this->_em->clear(); + + $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId)); + $this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->find($this->groupId2)); + } + + public function testRepositoryFindAll() + { + $this->loadFixtureData(); + + $this->assertCount(2, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll()); + + $this->useCMSGroupPrefixFilter(); + $this->_em->clear(); + + $this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll()); + } + + public function testRepositoryFindBy() + { + $this->loadFixtureData(); + + $this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findBy(array('id' => $this->groupId2))); + + $this->useCMSGroupPrefixFilter(); + $this->_em->clear(); + + $this->assertCount(0, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findBy(array('id' => $this->groupId2))); + } + + public function testRepositoryFindByX() + { + $this->loadFixtureData(); + + $this->assertCount(1, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findById($this->groupId2)); + + $this->useCMSGroupPrefixFilter(); + $this->_em->clear(); + + $this->assertCount(0, $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findById($this->groupId2)); + } + + public function testRepositoryFindOneBy() + { + $this->loadFixtureData(); + + $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneBy(array('id' => $this->groupId2))); + + $this->useCMSGroupPrefixFilter(); + $this->_em->clear(); + + $this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneBy(array('id' => $this->groupId2))); + } + + public function testRepositoryFindOneByX() + { + $this->loadFixtureData(); + + $this->assertNotNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneById($this->groupId2)); + + $this->useCMSGroupPrefixFilter(); + $this->_em->clear(); + + $this->assertNull($this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findOneById($this->groupId2)); + } + public function testToOneFilter() { //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);