[TASK] Namespace classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / DomainObject / AbstractEntityTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\DomainObject;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2009 Sebastian Kurf├╝rst <sebastian@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 class AbstractEntityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
27
28 /**
29 * @test
30 */
31 public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithSimpleProperties() {
32 $domainObjectName = uniqid('DomainObject_');
33 eval(('class ' . $domainObjectName) . ' extends TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {
34 public $foo;
35 public $bar;
36 }');
37 $domainObject = new $domainObjectName();
38 $domainObject->foo = 'Test';
39 $domainObject->bar = 'It is raining outside';
40 $domainObject->_memorizeCleanState();
41 $this->assertFalse($domainObject->_isDirty());
42 }
43
44 /**
45 * @test
46 */
47 public function objectIsDirtyAfterCallingMemorizeCleanStateWithSimplePropertiesAndModifyingThePropertiesAfterwards() {
48 $domainObjectName = uniqid('DomainObject_');
49 eval(('class ' . $domainObjectName) . ' extends TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {
50 public $foo;
51 public $bar;
52 }');
53 $domainObject = new $domainObjectName();
54 $domainObject->foo = 'Test';
55 $domainObject->bar = 'It is raining outside';
56 $domainObject->_memorizeCleanState();
57 $domainObject->bar = 'Now it is sunny.';
58 $this->assertTrue($domainObject->_isDirty());
59 }
60
61 /**
62 * @test
63 */
64 public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithObjectProperties() {
65 $domainObjectName = uniqid('DomainObject_');
66 eval(('class ' . $domainObjectName) . ' extends TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {
67 public $foo;
68 public $bar;
69 }');
70 $domainObject = new $domainObjectName();
71 $domainObject->foo = new \DateTime();
72 $domainObject->bar = 'It is raining outside';
73 $domainObject->_memorizeCleanState();
74 $this->assertFalse($domainObject->_isDirty());
75 }
76
77 /**
78 * @test
79 */
80 public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithOtherDomainObjectsAsProperties() {
81 $domainObjectName = uniqid('DomainObject_');
82 eval(('class ' . $domainObjectName) . ' extends TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {
83 public $foo;
84 public $bar;
85 }');
86 $secondDomainObjectName = uniqid('DomainObject_');
87 eval(('class ' . $secondDomainObjectName) . ' extends TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity {
88 public $foo;
89 public $bar;
90 }');
91 $secondDomainObject = new $secondDomainObjectName();
92 $secondDomainObject->_memorizeCleanState();
93 $domainObject = new $domainObjectName();
94 $domainObject->foo = $secondDomainObject;
95 $domainObject->bar = 'It is raining outside';
96 $domainObject->_memorizeCleanState();
97 $this->assertFalse($domainObject->_isDirty());
98 }
99
100 }
101
102
103 ?>