TYPO3 API  SVNRelease
AbstractEntityTest.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009 Sebastian Kurfürst <sebastian@typo3.org>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 class Tx_Extbase_Tests_Unit_DomainObject_AbstractEntityTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
00026 
00027     /**
00028      * @test
00029      */
00030     public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithSimpleProperties() {
00031         $domainObjectName = uniqid('DomainObject_');
00032         eval('class ' . $domainObjectName . ' extends Tx_Extbase_DomainObject_AbstractEntity {
00033             public $foo;
00034             public $bar;
00035         }');
00036         $domainObject = new $domainObjectName();
00037         $domainObject->foo = 'Test';
00038         $domainObject->bar = 'It is raining outside';
00039         $domainObject->_memorizeCleanState();
00040 
00041         $this->assertFalse($domainObject->_isDirty());
00042     }
00043 
00044     /**
00045      * @test
00046      */
00047     public function objectIsDirtyAfterCallingMemorizeCleanStateWithSimplePropertiesAndModifyingThePropertiesAfterwards() {
00048         $domainObjectName = uniqid('DomainObject_');
00049         eval('class ' . $domainObjectName . ' extends Tx_Extbase_DomainObject_AbstractEntity {
00050             public $foo;
00051             public $bar;
00052         }');
00053         $domainObject = new $domainObjectName();
00054         $domainObject->foo = 'Test';
00055         $domainObject->bar = 'It is raining outside';
00056 
00057         $domainObject->_memorizeCleanState();
00058         $domainObject->bar = 'Now it is sunny.';
00059 
00060         $this->assertTrue($domainObject->_isDirty());
00061     }
00062 
00063     /**
00064      * @test
00065      */
00066     public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithObjectProperties() {
00067         $domainObjectName = uniqid('DomainObject_');
00068         eval('class ' . $domainObjectName . ' extends Tx_Extbase_DomainObject_AbstractEntity {
00069             public $foo;
00070             public $bar;
00071         }');
00072         $domainObject = new $domainObjectName();
00073         $domainObject->foo = new DateTime();
00074         $domainObject->bar = 'It is raining outside';
00075         $domainObject->_memorizeCleanState();
00076 
00077         $this->assertFalse($domainObject->_isDirty());
00078     }
00079 
00080     /**
00081      * @test
00082      */
00083     public function objectIsNotDirtyAfterCallingMemorizeCleanStateWithOtherDomainObjectsAsProperties() {
00084         $domainObjectName = uniqid('DomainObject_');
00085         eval('class ' . $domainObjectName . ' extends Tx_Extbase_DomainObject_AbstractEntity {
00086             public $foo;
00087             public $bar;
00088         }');
00089 
00090         $secondDomainObjectName = uniqid('DomainObject_');
00091         eval('class ' . $secondDomainObjectName . ' extends Tx_Extbase_DomainObject_AbstractEntity {
00092             public $foo;
00093             public $bar;
00094         }');
00095         $secondDomainObject = new $secondDomainObjectName;
00096         $secondDomainObject->_memorizeCleanState();
00097 
00098 
00099         $domainObject = new $domainObjectName();
00100         $domainObject->foo = $secondDomainObject;
00101         $domainObject->bar = 'It is raining outside';
00102         $domainObject->_memorizeCleanState();
00103 
00104         $this->assertFalse($domainObject->_isDirty());
00105     }
00106 }
00107 ?>