[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / DomainObject / AbstractEntityTest.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Extbase\Tests\Unit\DomainObject;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19
20 /**
21 * Test case
22 */
23 class AbstractEntityTest extends UnitTestCase
24 {
25 /**
26 * @test
27 */
28 public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithSimpleProperties()
29 {
30 $domainObject = new class extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
31 public $foo = 'Test';
32 public $bar = 'It is raining outside';
33 };
34 $domainObject->_memorizeCleanState();
35
36 $this->assertFalse($domainObject->_isDirty());
37 }
38
39 /**
40 * @test
41 */
42 public function objectIsDirtyAfterCallingMemorizeCleanStateWithSimplePropertiesAndModifyingThePropertiesAfterwards()
43 {
44 $domainObject = new class extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
45 public $foo = 'Test';
46 public $bar = 'It is raining outside';
47 };
48 $domainObject->_memorizeCleanState();
49 $domainObject->bar = 'Now it is sunny.';
50
51 $this->assertTrue($domainObject->_isDirty());
52 }
53
54 /**
55 * @test
56 */
57 public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithObjectProperties()
58 {
59 $domainObject = new class extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
60 public $foo;
61 public $bar = 'It is raining outside';
62 };
63 $domainObject->foo = new \DateTime();
64 $domainObject->_memorizeCleanState();
65
66 $this->assertFalse($domainObject->_isDirty());
67 }
68
69 /**
70 * @test
71 */
72 public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithOtherDomainObjectsAsProperties()
73 {
74 $domainObject = new class extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
75 public $foo;
76 public $bar;
77 };
78
79 $secondDomainObject = new class extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
80 public $foo;
81 public $bar;
82 };
83
84 $secondDomainObject->_memorizeCleanState();
85 $domainObject->foo = $secondDomainObject;
86 $domainObject->bar = 'It is raining outside';
87 $domainObject->_memorizeCleanState();
88
89 $this->assertFalse($domainObject->_isDirty());
90 }
91 }