[BUBFIX] Fix fatal error in Test
authorHelmut Hummel <helmut.hummel@typo3.org>
Wed, 7 Nov 2012 17:25:30 +0000 (18:25 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 7 Nov 2012 17:26:42 +0000 (18:26 +0100)
Fixture class names have been used twice.
Use uniqid to avoid clashes.

Releases: 6.0
Relates: #42028

Change-Id: Iccf188969d988d259d7d5f5a4fa3bd194c1826c0
Reviewed-on: http://review.typo3.org/16259
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extbase/Tests/Unit/Persistence/PersistenceManagerTest.php
typo3/sysext/extbase/Tests/Unit/Reflection/ServiceTest.php

index f4cde16..ae37431 100644 (file)
@@ -37,16 +37,18 @@ class PersistenceManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
         * underscore class names instead of namespaced class names
         */
        public function persistAllAddsReconstitutedObjectFromSessionToBackendsAggregateRootObjects() {
+               $className = uniqid('BazFixture');
                eval ('
-                       class Foo_Bar_Domain_Model_BazFixture extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
+                       class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
                ');
                eval ('
-                       class Foo_Bar_Domain_Repository_BazFixtureRepository {}
+                       class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
                ');
 
                $persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
                $aggregateRootObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
-               $entity1 = new \Foo_Bar_Domain_Model_BazFixture();
+               $fullClassName = 'Foo_Bar_Domain_Model_' . $className;
+               $entity1 = new $fullClassName();
                $aggregateRootObjects->attach($entity1);
                $persistenceSession->registerReconstitutedObject($entity1);
                $mockTypo3DbBackend = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend'), array('commit','setAggregateRootObjects','setDeletedObjects'), array(), '', FALSE);
@@ -63,18 +65,20 @@ class PersistenceManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
         * @test
         */
        public function persistAllAddsNamespacedReconstitutedObjectFromSessionToBackendsAggregateRootObjects() {
+               $className = uniqid('BazFixture');
                eval ('
                        namespace Foo\\Bar\\Domain\\Model;
-                       class BazFixture extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
+                       class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
                ');
                eval ('
                        namespace Foo\\Bar\\Domain\\Repository;
-                       class BazFixtureRepository {}
+                       class  ' . $className . 'Repository {}
                ');
 
                $persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
                $aggregateRootObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
-               $entity1 = new \Foo\Bar\Domain\Model\BazFixture();
+               $classNameWithNamespace = 'Foo\\Bar\\Domain\\Model\\' . $className;
+               $entity1 = new $classNameWithNamespace();
                $aggregateRootObjects->attach($entity1);
                $persistenceSession->registerReconstitutedObject($entity1);
                $mockTypo3DbBackend = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend'), array('commit','setAggregateRootObjects','setDeletedObjects'), array(), '', FALSE);
index e8447dd..151db1e 100644 (file)
@@ -71,18 +71,19 @@ class ServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @test
         */
        public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNamespacedClasses() {
+               $className = uniqid('BazFixture');
                eval ('
                        namespace Foo\\Bar\\Domain\\Model;
-                       class BazFixture extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
+                       class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
                ');
                eval ('
                        namespace Foo\\Bar\\Domain\\Repository;
-                       class BazFixtureRepository {}
+                       class ' . $className . 'Repository {}
                ');
 
                $service = new \TYPO3\CMS\Extbase\Reflection\Service();
                $service->injectObjectManager($this->objectManager);
-               $classSchema = $service->getClassSchema('Foo\\Bar\\Domain\\Model\\BazFixture');
+               $classSchema = $service->getClassSchema('Foo\\Bar\\Domain\\Model\\' . $className);
                $this->assertTrue($classSchema->isAggregateRoot());
        }
 
@@ -90,16 +91,17 @@ class ServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
         * @test
         */
        public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNotNamespacedClasses() {
+               $className = uniqid('BazFixture');
                eval ('
-                       class Foo_Bar_Domain_Model_BazFixture extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
+                       class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
                ');
                eval ('
-                       class Foo_Bar_Domain_Repository_BazFixtureRepository {}
+                       class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
                ');
 
                $service = new \TYPO3\CMS\Extbase\Reflection\Service();
                $service->injectObjectManager($this->objectManager);
-               $classSchema = $service->getClassSchema('Foo_Bar_Domain_Model_BazFixture');
+               $classSchema = $service->getClassSchema('Foo_Bar_Domain_Model_' . $className);
                $this->assertTrue($classSchema->isAggregateRoot());
        }