TYPO3 CMS  TYPO3_8-7
AbstractEntityTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 class AbstractEntityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
26  {
27  $domainObjectName = $this->getUniqueId('DomainObject_');
28  $domainObjectNameWithNS = __NAMESPACE__ . '\\' . $domainObjectName;
29  eval('namespace ' . __NAMESPACE__ . '; class ' . $domainObjectName . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
30  public $foo;
31  public $bar;
32  }');
33  $domainObject = new $domainObjectNameWithNS();
34  $domainObject->foo = 'Test';
35  $domainObject->bar = 'It is raining outside';
36  $domainObject->_memorizeCleanState();
37  $this->assertFalse($domainObject->_isDirty());
38  }
39 
44  {
45  $domainObjectName = $this->getUniqueId('DomainObject_');
46  $domainObjectNameWithNS = __NAMESPACE__ . '\\' . $domainObjectName;
47  eval('namespace ' . __NAMESPACE__ . '; class ' . $domainObjectName . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
48  public $foo;
49  public $bar;
50  }');
51  $domainObject = new $domainObjectNameWithNS();
52  $domainObject->foo = 'Test';
53  $domainObject->bar = 'It is raining outside';
54  $domainObject->_memorizeCleanState();
55  $domainObject->bar = 'Now it is sunny.';
56  $this->assertTrue($domainObject->_isDirty());
57  }
58 
63  {
64  $domainObjectName = $this->getUniqueId('DomainObject_');
65  $domainObjectNameWithNS = __NAMESPACE__ . '\\' . $domainObjectName;
66  eval('namespace ' . __NAMESPACE__ . '; class ' . $domainObjectName . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
67  public $foo;
68  public $bar;
69  }');
70  $domainObject = new $domainObjectNameWithNS();
71  $domainObject->foo = new \DateTime();
72  $domainObject->bar = 'It is raining outside';
73  $domainObject->_memorizeCleanState();
74  $this->assertFalse($domainObject->_isDirty());
75  }
76 
81  {
82  $domainObjectName = $this->getUniqueId('DomainObject_');
83  $domainObjectNameWithNS = __NAMESPACE__ . '\\' . $domainObjectName;
84  eval('namespace ' . __NAMESPACE__ . '; class ' . $domainObjectName . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
85  public $foo;
86  public $bar;
87  }');
88  $secondDomainObjectName = $this->getUniqueId('DomainObject_');
89  $secondDomainObjectNameWithNS = __NAMESPACE__ . '\\' . $secondDomainObjectName;
90  eval('namespace ' . __NAMESPACE__ . '; class ' . $secondDomainObjectName . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
91  public $foo;
92  public $bar;
93  }');
94  $secondDomainObject = new $secondDomainObjectNameWithNS();
95  $secondDomainObject->_memorizeCleanState();
96  $domainObject = new $domainObjectNameWithNS();
97  $domainObject->foo = $secondDomainObject;
98  $domainObject->bar = 'It is raining outside';
99  $domainObject->_memorizeCleanState();
100  $this->assertFalse($domainObject->_isDirty());
101  }
102 }