[TASK] Adjust namespaces of persistence unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Persistence / Generic / PersistenceManagerTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic;
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 * A PersistenceManager Test
31 */
32 class PersistenceManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
33
34 /**
35 * @test
36 *
37 * This test and the related Fixtures TxDomainModelTestEntity and
38 * TxDomainRepositoryTestEntityRepository can be removed if we do not need to support
39 * underscore class names instead of namespaced class names
40 */
41 public function persistAllAddsReconstitutedObjectFromSessionToBackendsAggregateRootObjects() {
42 $className = uniqid('BazFixture');
43 eval ('
44 class Foo_Bar_Domain_Model_' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
45 ');
46 eval ('
47 class Foo_Bar_Domain_Repository_' . $className . 'Repository {}
48 ');
49
50 $persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
51 $aggregateRootObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
52 $fullClassName = 'Foo_Bar_Domain_Model_' . $className;
53 $entity1 = new $fullClassName();
54 $aggregateRootObjects->attach($entity1);
55 $persistenceSession->registerReconstitutedObject($entity1);
56 $mockTypo3DbBackend = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend'), array('commit', 'setAggregateRootObjects', 'setDeletedObjects'), array(), '', FALSE);
57 $persistenceManager = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'), array('dummy'), array(), '', FALSE);
58 $mockTypo3DbBackend->expects($this->once())
59 ->method('setAggregateRootObjects')
60 ->with($this->equalTo($aggregateRootObjects));
61 $persistenceManager->_set('backend', $mockTypo3DbBackend);
62 $persistenceManager->injectSession($persistenceSession);
63 $persistenceManager->persistAll();
64 }
65
66 /**
67 * @test
68 */
69 public function persistAllAddsNamespacedReconstitutedObjectFromSessionToBackendsAggregateRootObjects() {
70 $className = uniqid('BazFixture');
71 eval ('
72 namespace Foo\\Bar\\Domain\\Model;
73 class ' . $className . ' extends \\TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {}
74 ');
75 eval ('
76 namespace Foo\\Bar\\Domain\\Repository;
77 class ' . $className . 'Repository {}
78 ');
79
80 $persistenceSession = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
81 $aggregateRootObjects = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
82 $classNameWithNamespace = 'Foo\\Bar\\Domain\\Model\\' . $className;
83 $entity1 = new $classNameWithNamespace();
84 $aggregateRootObjects->attach($entity1);
85 $persistenceSession->registerReconstitutedObject($entity1);
86 $mockTypo3DbBackend = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Storage\\Typo3DbBackend'), array('commit', 'setAggregateRootObjects', 'setDeletedObjects'), array(), '', FALSE);
87 $persistenceManager = $this->getMock($this->buildAccessibleProxy('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'), array('dummy'), array(), '', FALSE);
88 $mockTypo3DbBackend->expects($this->once())
89 ->method('setAggregateRootObjects')
90 ->with($this->equalTo($aggregateRootObjects));
91 $persistenceManager->_set('backend', $mockTypo3DbBackend);
92 $persistenceManager->injectSession($persistenceSession);
93 $persistenceManager->persistAll();
94 }
95
96 /**
97 * @test
98 */
99 public function persistAllAddsRemovedObjectsFromRepositoriesToBackendsDeletedObjects() {
100 $this->markTestIncomplete();
101 }
102
103 /**
104 * @test
105 */
106 public function persistAllAddsAddedObjectsFromRepositoriesToBackendsAggregateRootObjects() {
107 $this->markTestIncomplete();
108 }
109 }
110
111 ?>