TYPO3 API  SVNRelease
SessionTest.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
00006 *  All rights reserved
00007 *
00008 *  This class is a backport of the corresponding class of FLOW3.
00009 *  All credits go to the v5 team.
00010 *
00011 *  This script is part of the TYPO3 project. The TYPO3 project is
00012 *  free software; you can redistribute it and/or modify
00013 *  it under the terms of the GNU General Public License as published by
00014 *  the Free Software Foundation; either version 2 of the License, or
00015 *  (at your option) any later version.
00016 *
00017 *  The GNU General Public License can be found at
00018 *  http://www.gnu.org/copyleft/gpl.html.
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 
00028 class Tx_Extbase_Tests_Unit_Persistence_SessionTest extends tx_phpunit_testcase {
00029 
00030     /**
00031      * @test
00032      */
00033     public function newSessionIsEmpty() {
00034         $persistenceSession = new Tx_Extbase_Persistence_Session;
00035         $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
00036         $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
00037     }
00038 
00039     /**
00040      * @test
00041      */
00042     public function objectCanBeRegisteredAsReconstituted() {
00043         $persistenceSession = new Tx_Extbase_Persistence_Session;
00044         $entity = $this->getMock('Tx_Extbase_DomainObject_AbstractEntity');
00045         $persistenceSession->registerReconstitutedObject($entity);
00046         $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
00047         $this->assertTrue($reconstitutedObjects->contains($entity), 'The object was not registered as reconstituted.');
00048     }
00049 
00050     /**
00051      * @test
00052      */
00053     public function objectCanBeUnregisteredAsReconstituted() {
00054         $persistenceSession = new Tx_Extbase_Persistence_Session;
00055         $entity = $this->getMock('Tx_Extbase_DomainObject_AbstractEntity');
00056         $persistenceSession->registerReconstitutedObject($entity);
00057         $persistenceSession->unregisterReconstitutedObject($entity);
00058         $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
00059 
00060         $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
00061     }
00062 
00063 }
00064 ?>