From e161103e4b3378290c8db072f6f4899bbbbbd7d5 Mon Sep 17 00:00:00 2001 From: romanb Date: Fri, 14 Aug 2009 11:04:31 +0000 Subject: [PATCH] [2.0] Added EntityRepositoryTest. Updated build file and XML Schema for mapping files. --- build.properties.dev | 2 +- build.xml | 16 ++--- doctrine-mapping.xsd | 68 +++++++++++++++--- .../Tests/ORM/Functional/AllTests.php | 1 + .../ORM/Functional/EntityRepositoryTest.php | 70 +++++++++++++++++++ .../Doctrine.Tests.ORM.Mapping.User.dcm.xml | 4 ++ 6 files changed, 143 insertions(+), 18 deletions(-) create mode 100644 tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php diff --git a/build.properties.dev b/build.properties.dev index d3a6b1835..5f9991d92 100644 --- a/build.properties.dev +++ b/build.properties.dev @@ -1,4 +1,4 @@ -version=2.0 +version=2.0-alpha1 build.dir=build dist.dir=dist report.dir=reports \ No newline at end of file diff --git a/build.xml b/build.xml index 521f6b619..d56d271d8 100644 --- a/build.xml +++ b/build.xml @@ -4,7 +4,7 @@ Doctrine 2 build file. --> - + @@ -71,8 +71,8 @@ - - + + @@ -104,7 +104,7 @@ Distributes the Doctrine Common package. --> - + @@ -115,7 +115,7 @@ Distributes the Doctrine DBAL package. --> - + @@ -126,9 +126,9 @@ DEFAULT TARGET Tests, builds and distributes the full Doctrine package (Common+DBAL+ORM). --> - - - + + + diff --git a/doctrine-mapping.xsd b/doctrine-mapping.xsd index 44120e2e2..3665c3193 100644 --- a/doctrine-mapping.xsd +++ b/doctrine-mapping.xsd @@ -15,7 +15,8 @@ - + + @@ -31,9 +32,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -43,17 +70,15 @@ + + - - - - - - - - + + + + @@ -71,6 +96,14 @@ + + + + + + + + @@ -78,6 +111,16 @@ + + + + + + + + + + @@ -102,6 +145,10 @@ + + + + @@ -116,6 +163,7 @@ + @@ -134,6 +182,7 @@ + @@ -147,6 +196,7 @@ + \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Functional/AllTests.php b/tests/Doctrine/Tests/ORM/Functional/AllTests.php index fa43b9aaf..22a8129d1 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AllTests.php +++ b/tests/Doctrine/Tests/ORM/Functional/AllTests.php @@ -39,6 +39,7 @@ class AllTests $suite->addTestSuite('Doctrine\Tests\ORM\Functional\LifecycleCallbackTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Functional\StandardEntityPersisterTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Functional\MappedSuperclassTest'); + $suite->addTestSuite('Doctrine\Tests\ORM\Functional\EntityRepositoryTest'); $suite->addTest(Locking\AllTests::suite()); diff --git a/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php new file mode 100644 index 000000000..0ffbc651c --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/EntityRepositoryTest.php @@ -0,0 +1,70 @@ +useModelSet('cms'); + parent::setUp(); + } + + public function testBasicFinders() { + $user = new CmsUser; + $user->name = 'Roman'; + $user->username = 'romanb'; + $user->status = 'freak'; + $this->_em->persist($user); + + $user2 = new CmsUser; + $user2->name = 'Guilherme'; + $user2->username = 'gblanco'; + $user2->status = 'dev'; + $this->_em->persist($user2); + + $this->_em->flush(); + $user1Id = $user->getId(); + unset($user); + unset($user2); + $this->_em->clear(); + + $repos = $this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'); + + $user = $repos->find($user1Id); + $this->assertTrue($user instanceof CmsUser); + $this->assertEquals('Roman', $user->name); + $this->assertEquals('freak', $user->status); + + $this->_em->clear(); + + $users = $repos->findBy(array('status' => 'dev')); + $this->assertEquals(1, count($users)); + $this->assertTrue($users[0] instanceof CmsUser); + $this->assertEquals('Guilherme', $users[0]->name); + $this->assertEquals('dev', $users[0]->status); + + $this->_em->clear(); + + $users = $repos->findByStatus('dev'); + $this->assertEquals(1, count($users)); + $this->assertTrue($users[0] instanceof CmsUser); + $this->assertEquals('Guilherme', $users[0]->name); + $this->assertEquals('dev', $users[0]->status); + + $this->_em->clear(); + + $users = $repos->findAll(); + $this->assertEquals(2, count($users)); + } +} + diff --git a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml index 34d28027e..a130ee1f5 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml +++ b/tests/Doctrine/Tests/ORM/Mapping/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml @@ -7,6 +7,10 @@ + + + +