[BUBFIX] Fix fatal error in Test
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Persistence / PersistenceManagerTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Nico de Haen
8 * All rights reserved
9 *
10 * This class is a backport of the corresponding class of FLOW3.
11 * All credits go to the v5 team.
12 *
13 * This script is part of the TYPO3 project. The TYPO3 project is
14 * free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * The GNU General Public License can be found at
20 * http://www.gnu.org/copyleft/gpl.html.
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 class PersistenceManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
31
32 /**
33 * @test
34 *
35 * This test and the related Fixtures TxDomainModelTestEntity and
36 * TxDomainRepositoryTestEntityRepository can be removed if we do not need to support
37 * underscore class names instead of namespaced class names
38 */
39 public function persistAllAddsReconstitutedObjectFromSessionToBackendsAggregateRootObjects() {
40 $className = uniqid('BazFixture');
41 eval ('
42 class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
43 ');
44 eval ('
45 class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
46 ');
47
48 $persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
49 $aggregateRootObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
50 $fullClassName = 'Foo_Bar_Domain_Model_' . $className;
51 $entity1 = new $fullClassName();
52 $aggregateRootObjects->attach($entity1);
53 $persistenceSession->registerReconstitutedObject($entity1);
54 $mockTypo3DbBackend = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend'), array('commit','setAggregateRootObjects','setDeletedObjects'), array(), '', FALSE);
55 $persistenceManager = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'), array('dummy'),array(), '', FALSE);
56 $mockTypo3DbBackend->expects($this->once())
57 ->method('setAggregateRootObjects')
58 ->with($this->equalTo($aggregateRootObjects));
59 $persistenceManager->_set('backend',$mockTypo3DbBackend);
60 $persistenceManager->injectSession($persistenceSession);
61 $persistenceManager->persistAll();
62 }
63
64 /**
65 * @test
66 */
67 public function persistAllAddsNamespacedReconstitutedObjectFromSessionToBackendsAggregateRootObjects() {
68 $className = uniqid('BazFixture');
69 eval ('
70 namespace Foo\\Bar\\Domain\\Model;
71 class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
72 ');
73 eval ('
74 namespace Foo\\Bar\\Domain\\Repository;
75 class ' . $className . 'Repository {}
76 ');
77
78 $persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
79 $aggregateRootObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
80 $classNameWithNamespace = 'Foo\\Bar\\Domain\\Model\\' . $className;
81 $entity1 = new $classNameWithNamespace();
82 $aggregateRootObjects->attach($entity1);
83 $persistenceSession->registerReconstitutedObject($entity1);
84 $mockTypo3DbBackend = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend'), array('commit','setAggregateRootObjects','setDeletedObjects'), array(), '', FALSE);
85 $persistenceManager = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'), array('dummy'),array(), '', FALSE);
86 $mockTypo3DbBackend->expects($this->once())
87 ->method('setAggregateRootObjects')
88 ->with($this->equalTo($aggregateRootObjects));
89 $persistenceManager->_set('backend',$mockTypo3DbBackend);
90 $persistenceManager->injectSession($persistenceSession);
91 $persistenceManager->persistAll();
92 }
93
94 /**
95 * @test
96 */
97 public function persistAllAddsRemovedObjectsFromRepositoriesToBackendsDeletedObjects() {
98 $this->markTestIncomplete();
99 }
100
101 /**
102 * @test
103 */
104 public function persistAllAddsAddedObjectsFromRepositoriesToBackendsAggregateRootObjects() {
105 $this->markTestIncomplete();
106 }
107
108 }
109 ?>