ExtBase:
authorJochen Rau <j.rau@web.de>
Sat, 28 Mar 2009 07:38:32 +0000 (07:38 +0000)
committerJochen Rau <j.rau@web.de>
Sat, 28 Mar 2009 07:38:32 +0000 (07:38 +0000)
* Reorganized folder structure of the tests

typo3/sysext/extbase/Tests/DataMap_testcase.php [deleted file]
typo3/sysext/extbase/Tests/ObjectRelationalMapper_testcase.php [deleted file]
typo3/sysext/extbase/Tests/ObjectStorage_testcase.php [deleted file]
typo3/sysext/extbase/Tests/Persistence/Mapper/DataMap_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Persistence/Mapper/ObjectRelationalMapper_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Persistence/ObjectStorage_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Persistence/Repository_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Persistence/Session_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Repository_testcase.php [deleted file]
typo3/sysext/extbase/Tests/Session_testcase.php [deleted file]

diff --git a/typo3/sysext/extbase/Tests/DataMap_testcase.php b/typo3/sysext/extbase/Tests/DataMap_testcase.php
deleted file mode 100644 (file)
index 4e66c20..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-require_once(PATH_tslib . 'class.tslib_content.php');
-
-class Tx_ExtBase_Persistence_Mapper_DataMap_testcase extends Tx_ExtBase_Base_testcase {
-       
-       public function setUp() {
-               require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/Model/Blog.php');
-       
-               $GLOBALS['TSFE']->fe_user = $this->getMock('tslib_feUserAuth');
-               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
-               $this->setupTca();
-               $GLOBALS['TSFE']->expects($this->any())
-                       ->method('includeTCA')
-                       ->will($this->returnValue(NULL));
-               
-               
-               $GLOBALS['TSFE']->fe_user->user['uid'] = 999;
-               $GLOBALS['TSFE']->id = 42;              
-       }
-       
-       public function setupTCA() {
-               global $TCA;
-               global $_EXTKEY;
-               $TCA['tx_blogexample_domain_model_blog'] = array (
-                       'ctrl' => array (
-                               'title'             => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog',
-                               'label'                         => 'name',
-                               'tstamp'            => 'tstamp',
-                               'prependAtCopy'     => 'LLL:EXT:lang/locallang_general.xml:LGL.prependAtCopy',
-                               'delete'            => 'deleted',
-                               'enablecolumns'     => array (
-                                       'disabled' => 'hidden'
-                               ),
-                               'iconfile'          => t3lib_extMgm::extRelPath($_EXTKEY).'Resources/Icons/icon_tx_blogexample_domain_model_blog.gif'
-                       ),
-                       'interface' => array(
-                               'showRecordFieldList' => 'hidden, name, description, logo, posts'
-                       ),
-                       'columns' => array(
-                               'hidden' => array(
-                                       'exclude' => 1,
-                                       'label'   => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
-                                       'config'  => array(
-                                               'type' => 'check'
-                                       )
-                               ),
-                               'name' => array(
-                                       'exclude' => 0,
-                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.name',
-                                       'config'  => array(
-                                               'type' => 'input',
-                                               'size' => 20,
-                                               'eval' => 'trim,required',
-                                               'max'  => 256
-                                       )
-                               ),
-                               'description' => array(
-                                       'exclude' => 1,
-                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.description',
-                                       'config'  => array(
-                                               'type' => 'text',
-                                               'eval' => 'required',
-                                               'rows' => 30,
-                                               'cols' => 80,
-                                       )
-                               ),
-                               'logo' => array(
-                                       'exclude' => 1,
-                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.logo',
-                                       'config'  => array(
-                                               'type'          => 'group',
-                                               'internal_type' => 'file',
-                                               'allowed'       => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
-                                               'max_size'      => 3000,
-                                               'uploadfolder'  => 'uploads/pics',
-                                               'show_thumbs'   => 1,
-                                               'size'          => 1,
-                                               'maxitems'      => 1,
-                                               'minitems'      => 0
-                                       )
-                               ),
-                               'posts' => array(
-                                       'exclude' => 1,
-                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.posts',
-                                       'config' => array(
-                                               'type' => 'inline',
-                                               // TODO is 'foreign_class' in $TCA the best way?
-                                               'foreign_class' => 'Tx_BlogExample_Domain_Model_Post',
-                                               'foreign_table' => 'tx_blogexample_domain_model_post',
-                                               'foreign_field' => 'blog',
-                                               'foreign_table_field' => 'blog_table',
-                                               'appearance' => array(
-                                                       'newRecordLinkPosition' => 'bottom',
-                                                       'collapseAll' => 1,
-                                                       'expandSingle' => 1,
-                                               ),
-                                       )
-                               ),
-                               'author' => array(
-                                       'exclude' => 1,
-                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.author',
-                                       'config' => array(
-                                               'type' => 'select',
-                                               'foreign_class' => 'Tx_BlogExample_Domain_Model_Author',
-                                               'foreign_table' => 'tx_blogexample_domain_model_author',
-                                               'maxitems' => 1,
-                                       )
-                               ),
-                       ),
-                       'types' => array(
-                               '1' => array('showitem' => 'hidden, name, description, logo, posts')
-                       ),
-                       'palettes' => array(
-                               '1' => array('showitem' => '')
-                       )
-               );
-       }
-
-       public function test_DataMapCanBeInitialized() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $dataMap->initialize();
-               $columnMaps = $dataMap->getColumnMaps();
-               $this->assertEquals(12, count($columnMaps), 'The data map was not initialized (wrong number of column maps set).');
-       }
-       
-       public function test_DeletedColumnNameCanBeResolved() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $deletedColumnName = $dataMap->getDeletedColumnName();
-               $this->assertEquals($deletedColumnName, 'deleted', 'The deleted column name could not be resolved.');
-       }
-       
-       public function test_HiddenColumnNameCanBeResolved() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $hiddenColumnName = $dataMap->getHiddenColumnName();
-               $this->assertEquals($hiddenColumnName, 'hidden', 'The hidden column name could not be resolved.');
-       }
-       
-       public function test_ColumnCanBeAdded() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $dataMap->addColumn('test_column');
-               $columnMaps = $dataMap->getColumnMaps();
-               $columnMap = array_pop($columnMaps);
-               $this->assertType('Tx_ExtBase_Persistence_Mapper_ColumnMap', $columnMap, 'The column could not be added.');
-       }
-       
-       public function test_ColumnListCanBeRetrieved() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $dataMap->addColumn('column1');
-               $dataMap->addColumn('column2');
-               $dataMap->addColumn('column3');
-               $dataMap->addColumn('column4');
-               $columnList = $dataMap->getColumnList();
-               $this->assertEquals($columnList, 'column1,column2,column3,column4', 'The column list could not be retrieved.');
-       }
-       
-       public function test_PersistablePropertyCanBeChecked() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $dataMap->addColumn('configured_property');
-               $this->assertTrue($dataMap->isPersistableProperty('configuredProperty'), 'The persistable property was marked as unpersistable.');
-               $this->assertFalse($dataMap->isPersistableProperty('unconfiguredProperty'), 'The unpersistable property was marked asersistable.');
-       }
-       
-       public function test_HasManyColumnIsRegisteredForForeignTable() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $dataMap->initialize();
-               $this->assertEquals(Tx_ExtBase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY, $dataMap->getColumnMap('posts')->getTypeOfRelation(), 'The posts relation was not of type HAS_MANY.');
-       }
-       
-       public function test_HasOneColumnIsRegisteredForForeignTableWithMaxsizeOne() {
-               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
-               $dataMap->initialize();
-               $this->assertEquals(Tx_ExtBase_Persistence_Mapper_ColumnMap::RELATION_HAS_ONE, $dataMap->getColumnMap('author')->getTypeOfRelation(), 'The author relation was not of type HAS_ONE.');
-       }
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/ObjectRelationalMapper_testcase.php b/typo3/sysext/extbase/Tests/ObjectRelationalMapper_testcase.php
deleted file mode 100644 (file)
index c5a8cdb..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-class Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper_testcase extends Tx_ExtBase_Base_testcase {
-
-       public function setUp() {
-               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
-               $GLOBALS['TSFE']->expects($this->any())
-                       ->method('includeTCA')
-                       ->will($this->returnValue(NULL));
-               
-               $this->typo3Db = $GLOBALS['TYPO3_DB'];
-               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
-       }
-       
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->typo3Db;
-       }
-
-       public function test_BuildQueryWithPlaceholders() {
-               $mapper = new Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper();
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-
-               $GLOBALS['TYPO3_DB']->expects($this->at(1))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('bar'))
-                       ->will($this->returnValue('"bar"'));
-               
-               $query = $mapper->buildQuery('Tx_BlogExample_Domain_Blog',
-                       array(
-                               array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
-                               array('hidden = ?', FALSE)
-                       ));
-               
-               $this->assertEquals('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)', $query);
-       }
-
-       public function test_BuildQueryWithExample() {
-               $mapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('getDataMap'));
-       
-               $columnMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
-               $columnMap1->expects($this->once())
-                       ->method('getColumnName')
-                       ->will($this->returnValue('blog_name'));
-
-               $columnMap2 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
-               $columnMap2->expects($this->once())
-                       ->method('getColumnName')
-                       ->will($this->returnValue('hidden'));
-
-               $dataMap = $this->getMock('Tx_ExtBase_Persistence_Mapper_DataMap', array('getColumnMap', 'getTableName'), array(), '', FALSE);
-
-               $dataMap->expects($this->at(0))
-                       ->method('getColumnMap')
-                       ->with($this->equalTo('blogName'))
-                       ->will($this->returnValue($columnMap1));
-
-               $dataMap->expects($this->at(1))
-                       ->method('getTableName')
-                       ->will($this->returnValue('tx_blogexample_domain_model_blog'));
-
-               $dataMap->expects($this->at(2))
-                       ->method('getColumnMap')
-                       ->with($this->equalTo('hidden'))
-                       ->will($this->returnValue($columnMap2));
-
-               $dataMap->expects($this->at(3))
-                       ->method('getTableName')
-                       ->will($this->returnValue('tx_blogexample_domain_model_blog'));
-               
-               $mapper->expects($this->any())
-                       ->method('getDataMap')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'))
-                       ->will($this->returnValue($dataMap));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->at(0))
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('foo'))
-                       ->will($this->returnValue('"foo"'));
-               
-               $query = $mapper->buildQuery('Tx_BlogExample_Domain_Model_Blog',
-                       array(
-                               'blogName' => 'foo',
-                               'hidden' => FALSE
-                       ));
-               
-               $this->assertEquals('(tx_blogexample_domain_model_blog.blog_name = "foo") AND (tx_blogexample_domain_model_blog.hidden = 0)', $query);
-       }
-       
-       public function test_BuildQueryWithNestedExample() {
-               $mapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('getDataMap'));
-
-               $columnMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
-               $columnMap1->expects($this->once())
-                       ->method('getColumnName')
-                       ->will($this->returnValue('hidden'));
-
-               $columnMap3 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getChildClassName'), array(), '', FALSE);
-               $columnMap3->expects($this->once())
-                       ->method('getChildClassName')
-                       ->will($this->returnValue('Tx_BlogExample_Domain_Model_Author'));
-
-               $dataMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_DataMap', array('getColumnMap', 'getTableName'), array(), '', FALSE);
-               $dataMap1->expects($this->at(0))
-                       ->method('getColumnMap')
-                       ->with($this->equalTo('hidden'))
-                       ->will($this->returnValue($columnMap1));
-               $dataMap1->expects($this->at(1))
-                       ->method('getTableName')
-                       ->will($this->returnValue('tx_blogexample_domain_model_blog'));
-               $dataMap1->expects($this->at(2))
-                       ->method('getColumnMap')
-                       ->with($this->equalTo('author'))
-                       ->will($this->returnValue($columnMap3));
-
-               $columnMap2 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
-               $columnMap2->expects($this->once())
-                       ->method('getColumnName')
-                       ->will($this->returnValue('name'));
-
-               $dataMap2 = $this->getMock('Tx_ExtBase_Persistence_Mapper_DataMap', array('getColumnMap', 'getTableName'), array(), '', FALSE);
-               $dataMap2->expects($this->at(0))
-                       ->method('getColumnMap')
-                       ->with($this->equalTo('name'))
-                       ->will($this->returnValue($columnMap2));
-               $dataMap2->expects($this->at(1))
-                       ->method('getTableName')
-                       ->will($this->returnValue('tx_blogexample_domain_model_author'));
-               
-               $mapper->expects($this->at(0))
-                       ->method('getDataMap')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'))
-                       ->will($this->returnValue($dataMap1));
-               
-               $mapper->expects($this->at(1))
-                       ->method('getDataMap')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Author'))
-                       ->will($this->returnValue($dataMap2));
-               
-               $GLOBALS['TYPO3_DB']->expects($this->any())
-                       ->method('fullQuoteStr')
-                       ->with($this->equalTo('Christopher'))
-                       ->will($this->returnValue('"Christopher"'));
-               
-               $query = $mapper->buildQuery('Tx_BlogExample_Domain_Model_Blog',
-                       array(
-                               'hidden' => FALSE,
-                               'author' => array(
-                                       'name' => 'Christopher'
-                               )
-                       ));
-               
-               $this->assertEquals('(tx_blogexample_domain_model_blog.hidden = 0) AND ((tx_blogexample_domain_model_author.name = "Christopher"))', $query);
-       }
-       
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/ObjectStorage_testcase.php b/typo3/sysext/extbase/Tests/ObjectStorage_testcase.php
deleted file mode 100644 (file)
index 0237de0..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-class Tx_ExtBase_Persistence_ObjectStorage_testcase extends Tx_ExtBase_Base_testcase {
-       
-       public function setUp() {
-       }
-       
-       public function test_AnObjectCanBeAttached() {
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage->attach($object);
-               $result = $objectStorage->offsetGet($object);
-               $this->assertEquals($result, $object, 'The retrieved object differs from the attached object.');                
-       }
-       
-       public function test_AttachingSomethingElseThanAnObjectThrowsAnException() {
-               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $objectStorage->attach('foo');
-       }
-       
-       public function test_AnObjectCanBeDetached() {
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage->offsetSet($object, $object);
-               $resultBeforeDetaching = $objectStorage->offsetGet($object);
-               $this->assertEquals($resultBeforeDetaching, $object, 'The object could not be set via offsetSet().');           
-               $objectStorage->detach($object);
-               $resultAfterDetaching = $objectStorage->offsetGet($object);
-               $this->assertEquals($resultAfterDetaching, NULL, 'The object could not be detached.');          
-       }
-       
-       public function test_DetachingSomethingElseThanAnObjectThrowsAnException() {
-               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $objectStorage->detach('foo');
-       }
-       
-       public function test_AddingAnObjectWithoutAnObjectAsOffsetThrowsAnException() {
-               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage[] = $object;
-       }
-               
-       public function test_AddingAValueOtherThanAnObjectThrowsAnException() {
-               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage[$object] = 'foo';
-       }
-       
-       public function test_IfTheOffsetAndTheValueAreNotEqualAnExceptionIsThrown() {
-               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $object2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage[$object1] = $object2;
-       }       
-       
-       public function test_AnObjectCouldBeSetViaAnOffset() {
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage[$object] = $object;
-               $result = $objectStorage->offsetGet($object);
-               $this->assertEquals($result, $object, 'The retrieved object differs from the attached object.');
-       }
-       
-       public function test_ItCanBeTestedIfTheStorageContainsAnObject() {
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage->attach($object);
-               $result = $objectStorage->contains($object);
-               $this->assertEquals($result, TRUE, 'The method object differs from the attached object.');              
-       }
-       
-       public function test_UnsettingSomethingElseThanAnObjectThrowsAnException() {
-               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               // $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               // $objectStorage->offsetSet($object, $object);
-               $objectStorage->offsetUnset('foo');
-       }
-
-       public function test_AnObjectCanBeUnset() {
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage->offsetSet($object, $object);
-               $resultBeforeDetaching = $objectStorage->offsetGet($object);
-               $this->assertEquals($resultBeforeDetaching, $object, 'The object could not be set via offsetSet().');           
-               $objectStorage->offsetUnset($object);
-               $resultAfterDetaching = $objectStorage->offsetGet($object);
-               $this->assertEquals($resultAfterDetaching, NULL, 'The object could not be unsetted.');          
-       }
-
-       public function test_TheStorageCanBeRetrievedAsArray() {
-               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
-               $object1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage->offsetSet($object1, $object1);
-               $object2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $objectStorage->offsetSet($object2, $object2);
-               $result = $objectStorage->toArray();
-               $this->assertEquals(is_array($result), TRUE, 'The result was not an array as expected.');               
-               $this->assertEquals(count($result), 2, 'The retrieved array did not contain two elements.');            
-       }
-
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Persistence/Mapper/DataMap_testcase.php b/typo3/sysext/extbase/Tests/Persistence/Mapper/DataMap_testcase.php
new file mode 100644 (file)
index 0000000..4e66c20
--- /dev/null
@@ -0,0 +1,198 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+require_once(PATH_tslib . 'class.tslib_content.php');
+
+class Tx_ExtBase_Persistence_Mapper_DataMap_testcase extends Tx_ExtBase_Base_testcase {
+       
+       public function setUp() {
+               require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/Model/Blog.php');
+       
+               $GLOBALS['TSFE']->fe_user = $this->getMock('tslib_feUserAuth');
+               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
+               $this->setupTca();
+               $GLOBALS['TSFE']->expects($this->any())
+                       ->method('includeTCA')
+                       ->will($this->returnValue(NULL));
+               
+               
+               $GLOBALS['TSFE']->fe_user->user['uid'] = 999;
+               $GLOBALS['TSFE']->id = 42;              
+       }
+       
+       public function setupTCA() {
+               global $TCA;
+               global $_EXTKEY;
+               $TCA['tx_blogexample_domain_model_blog'] = array (
+                       'ctrl' => array (
+                               'title'             => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog',
+                               'label'                         => 'name',
+                               'tstamp'            => 'tstamp',
+                               'prependAtCopy'     => 'LLL:EXT:lang/locallang_general.xml:LGL.prependAtCopy',
+                               'delete'            => 'deleted',
+                               'enablecolumns'     => array (
+                                       'disabled' => 'hidden'
+                               ),
+                               'iconfile'          => t3lib_extMgm::extRelPath($_EXTKEY).'Resources/Icons/icon_tx_blogexample_domain_model_blog.gif'
+                       ),
+                       'interface' => array(
+                               'showRecordFieldList' => 'hidden, name, description, logo, posts'
+                       ),
+                       'columns' => array(
+                               'hidden' => array(
+                                       'exclude' => 1,
+                                       'label'   => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
+                                       'config'  => array(
+                                               'type' => 'check'
+                                       )
+                               ),
+                               'name' => array(
+                                       'exclude' => 0,
+                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.name',
+                                       'config'  => array(
+                                               'type' => 'input',
+                                               'size' => 20,
+                                               'eval' => 'trim,required',
+                                               'max'  => 256
+                                       )
+                               ),
+                               'description' => array(
+                                       'exclude' => 1,
+                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.description',
+                                       'config'  => array(
+                                               'type' => 'text',
+                                               'eval' => 'required',
+                                               'rows' => 30,
+                                               'cols' => 80,
+                                       )
+                               ),
+                               'logo' => array(
+                                       'exclude' => 1,
+                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.logo',
+                                       'config'  => array(
+                                               'type'          => 'group',
+                                               'internal_type' => 'file',
+                                               'allowed'       => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
+                                               'max_size'      => 3000,
+                                               'uploadfolder'  => 'uploads/pics',
+                                               'show_thumbs'   => 1,
+                                               'size'          => 1,
+                                               'maxitems'      => 1,
+                                               'minitems'      => 0
+                                       )
+                               ),
+                               'posts' => array(
+                                       'exclude' => 1,
+                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.posts',
+                                       'config' => array(
+                                               'type' => 'inline',
+                                               // TODO is 'foreign_class' in $TCA the best way?
+                                               'foreign_class' => 'Tx_BlogExample_Domain_Model_Post',
+                                               'foreign_table' => 'tx_blogexample_domain_model_post',
+                                               'foreign_field' => 'blog',
+                                               'foreign_table_field' => 'blog_table',
+                                               'appearance' => array(
+                                                       'newRecordLinkPosition' => 'bottom',
+                                                       'collapseAll' => 1,
+                                                       'expandSingle' => 1,
+                                               ),
+                                       )
+                               ),
+                               'author' => array(
+                                       'exclude' => 1,
+                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.author',
+                                       'config' => array(
+                                               'type' => 'select',
+                                               'foreign_class' => 'Tx_BlogExample_Domain_Model_Author',
+                                               'foreign_table' => 'tx_blogexample_domain_model_author',
+                                               'maxitems' => 1,
+                                       )
+                               ),
+                       ),
+                       'types' => array(
+                               '1' => array('showitem' => 'hidden, name, description, logo, posts')
+                       ),
+                       'palettes' => array(
+                               '1' => array('showitem' => '')
+                       )
+               );
+       }
+
+       public function test_DataMapCanBeInitialized() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $dataMap->initialize();
+               $columnMaps = $dataMap->getColumnMaps();
+               $this->assertEquals(12, count($columnMaps), 'The data map was not initialized (wrong number of column maps set).');
+       }
+       
+       public function test_DeletedColumnNameCanBeResolved() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $deletedColumnName = $dataMap->getDeletedColumnName();
+               $this->assertEquals($deletedColumnName, 'deleted', 'The deleted column name could not be resolved.');
+       }
+       
+       public function test_HiddenColumnNameCanBeResolved() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $hiddenColumnName = $dataMap->getHiddenColumnName();
+               $this->assertEquals($hiddenColumnName, 'hidden', 'The hidden column name could not be resolved.');
+       }
+       
+       public function test_ColumnCanBeAdded() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $dataMap->addColumn('test_column');
+               $columnMaps = $dataMap->getColumnMaps();
+               $columnMap = array_pop($columnMaps);
+               $this->assertType('Tx_ExtBase_Persistence_Mapper_ColumnMap', $columnMap, 'The column could not be added.');
+       }
+       
+       public function test_ColumnListCanBeRetrieved() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $dataMap->addColumn('column1');
+               $dataMap->addColumn('column2');
+               $dataMap->addColumn('column3');
+               $dataMap->addColumn('column4');
+               $columnList = $dataMap->getColumnList();
+               $this->assertEquals($columnList, 'column1,column2,column3,column4', 'The column list could not be retrieved.');
+       }
+       
+       public function test_PersistablePropertyCanBeChecked() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $dataMap->addColumn('configured_property');
+               $this->assertTrue($dataMap->isPersistableProperty('configuredProperty'), 'The persistable property was marked as unpersistable.');
+               $this->assertFalse($dataMap->isPersistableProperty('unconfiguredProperty'), 'The unpersistable property was marked asersistable.');
+       }
+       
+       public function test_HasManyColumnIsRegisteredForForeignTable() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $dataMap->initialize();
+               $this->assertEquals(Tx_ExtBase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY, $dataMap->getColumnMap('posts')->getTypeOfRelation(), 'The posts relation was not of type HAS_MANY.');
+       }
+       
+       public function test_HasOneColumnIsRegisteredForForeignTableWithMaxsizeOne() {
+               $dataMap = new Tx_ExtBase_Persistence_Mapper_DataMap('Tx_BlogExample_Domain_Model_Blog');
+               $dataMap->initialize();
+               $this->assertEquals(Tx_ExtBase_Persistence_Mapper_ColumnMap::RELATION_HAS_ONE, $dataMap->getColumnMap('author')->getTypeOfRelation(), 'The author relation was not of type HAS_ONE.');
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Persistence/Mapper/ObjectRelationalMapper_testcase.php b/typo3/sysext/extbase/Tests/Persistence/Mapper/ObjectRelationalMapper_testcase.php
new file mode 100644 (file)
index 0000000..c5a8cdb
--- /dev/null
@@ -0,0 +1,182 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+class Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper_testcase extends Tx_ExtBase_Base_testcase {
+
+       public function setUp() {
+               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
+               $GLOBALS['TSFE']->expects($this->any())
+                       ->method('includeTCA')
+                       ->will($this->returnValue(NULL));
+               
+               $this->typo3Db = $GLOBALS['TYPO3_DB'];
+               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
+       }
+       
+       public function tearDown() {
+               $GLOBALS['TYPO3_DB'] = $this->typo3Db;
+       }
+
+       public function test_BuildQueryWithPlaceholders() {
+               $mapper = new Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper();
+               
+               $GLOBALS['TYPO3_DB']->expects($this->at(0))
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('foo'))
+                       ->will($this->returnValue('"foo"'));
+
+               $GLOBALS['TYPO3_DB']->expects($this->at(1))
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('bar'))
+                       ->will($this->returnValue('"bar"'));
+               
+               $query = $mapper->buildQuery('Tx_BlogExample_Domain_Blog',
+                       array(
+                               array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
+                               array('hidden = ?', FALSE)
+                       ));
+               
+               $this->assertEquals('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)', $query);
+       }
+
+       public function test_BuildQueryWithExample() {
+               $mapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('getDataMap'));
+       
+               $columnMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
+               $columnMap1->expects($this->once())
+                       ->method('getColumnName')
+                       ->will($this->returnValue('blog_name'));
+
+               $columnMap2 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
+               $columnMap2->expects($this->once())
+                       ->method('getColumnName')
+                       ->will($this->returnValue('hidden'));
+
+               $dataMap = $this->getMock('Tx_ExtBase_Persistence_Mapper_DataMap', array('getColumnMap', 'getTableName'), array(), '', FALSE);
+
+               $dataMap->expects($this->at(0))
+                       ->method('getColumnMap')
+                       ->with($this->equalTo('blogName'))
+                       ->will($this->returnValue($columnMap1));
+
+               $dataMap->expects($this->at(1))
+                       ->method('getTableName')
+                       ->will($this->returnValue('tx_blogexample_domain_model_blog'));
+
+               $dataMap->expects($this->at(2))
+                       ->method('getColumnMap')
+                       ->with($this->equalTo('hidden'))
+                       ->will($this->returnValue($columnMap2));
+
+               $dataMap->expects($this->at(3))
+                       ->method('getTableName')
+                       ->will($this->returnValue('tx_blogexample_domain_model_blog'));
+               
+               $mapper->expects($this->any())
+                       ->method('getDataMap')
+                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'))
+                       ->will($this->returnValue($dataMap));
+               
+               $GLOBALS['TYPO3_DB']->expects($this->at(0))
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('foo'))
+                       ->will($this->returnValue('"foo"'));
+               
+               $query = $mapper->buildQuery('Tx_BlogExample_Domain_Model_Blog',
+                       array(
+                               'blogName' => 'foo',
+                               'hidden' => FALSE
+                       ));
+               
+               $this->assertEquals('(tx_blogexample_domain_model_blog.blog_name = "foo") AND (tx_blogexample_domain_model_blog.hidden = 0)', $query);
+       }
+       
+       public function test_BuildQueryWithNestedExample() {
+               $mapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('getDataMap'));
+
+               $columnMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
+               $columnMap1->expects($this->once())
+                       ->method('getColumnName')
+                       ->will($this->returnValue('hidden'));
+
+               $columnMap3 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getChildClassName'), array(), '', FALSE);
+               $columnMap3->expects($this->once())
+                       ->method('getChildClassName')
+                       ->will($this->returnValue('Tx_BlogExample_Domain_Model_Author'));
+
+               $dataMap1 = $this->getMock('Tx_ExtBase_Persistence_Mapper_DataMap', array('getColumnMap', 'getTableName'), array(), '', FALSE);
+               $dataMap1->expects($this->at(0))
+                       ->method('getColumnMap')
+                       ->with($this->equalTo('hidden'))
+                       ->will($this->returnValue($columnMap1));
+               $dataMap1->expects($this->at(1))
+                       ->method('getTableName')
+                       ->will($this->returnValue('tx_blogexample_domain_model_blog'));
+               $dataMap1->expects($this->at(2))
+                       ->method('getColumnMap')
+                       ->with($this->equalTo('author'))
+                       ->will($this->returnValue($columnMap3));
+
+               $columnMap2 = $this->getMock('Tx_ExtBase_Persistence_Mapper_ColumnMap', array('getColumnName'), array(), '', FALSE);
+               $columnMap2->expects($this->once())
+                       ->method('getColumnName')
+                       ->will($this->returnValue('name'));
+
+               $dataMap2 = $this->getMock('Tx_ExtBase_Persistence_Mapper_DataMap', array('getColumnMap', 'getTableName'), array(), '', FALSE);
+               $dataMap2->expects($this->at(0))
+                       ->method('getColumnMap')
+                       ->with($this->equalTo('name'))
+                       ->will($this->returnValue($columnMap2));
+               $dataMap2->expects($this->at(1))
+                       ->method('getTableName')
+                       ->will($this->returnValue('tx_blogexample_domain_model_author'));
+               
+               $mapper->expects($this->at(0))
+                       ->method('getDataMap')
+                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'))
+                       ->will($this->returnValue($dataMap1));
+               
+               $mapper->expects($this->at(1))
+                       ->method('getDataMap')
+                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Author'))
+                       ->will($this->returnValue($dataMap2));
+               
+               $GLOBALS['TYPO3_DB']->expects($this->any())
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('Christopher'))
+                       ->will($this->returnValue('"Christopher"'));
+               
+               $query = $mapper->buildQuery('Tx_BlogExample_Domain_Model_Blog',
+                       array(
+                               'hidden' => FALSE,
+                               'author' => array(
+                                       'name' => 'Christopher'
+                               )
+                       ));
+               
+               $this->assertEquals('(tx_blogexample_domain_model_blog.hidden = 0) AND ((tx_blogexample_domain_model_author.name = "Christopher"))', $query);
+       }
+       
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Persistence/ObjectStorage_testcase.php b/typo3/sysext/extbase/Tests/Persistence/ObjectStorage_testcase.php
new file mode 100644 (file)
index 0000000..0237de0
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+class Tx_ExtBase_Persistence_ObjectStorage_testcase extends Tx_ExtBase_Base_testcase {
+       
+       public function setUp() {
+       }
+       
+       public function test_AnObjectCanBeAttached() {
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage->attach($object);
+               $result = $objectStorage->offsetGet($object);
+               $this->assertEquals($result, $object, 'The retrieved object differs from the attached object.');                
+       }
+       
+       public function test_AttachingSomethingElseThanAnObjectThrowsAnException() {
+               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $objectStorage->attach('foo');
+       }
+       
+       public function test_AnObjectCanBeDetached() {
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage->offsetSet($object, $object);
+               $resultBeforeDetaching = $objectStorage->offsetGet($object);
+               $this->assertEquals($resultBeforeDetaching, $object, 'The object could not be set via offsetSet().');           
+               $objectStorage->detach($object);
+               $resultAfterDetaching = $objectStorage->offsetGet($object);
+               $this->assertEquals($resultAfterDetaching, NULL, 'The object could not be detached.');          
+       }
+       
+       public function test_DetachingSomethingElseThanAnObjectThrowsAnException() {
+               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $objectStorage->detach('foo');
+       }
+       
+       public function test_AddingAnObjectWithoutAnObjectAsOffsetThrowsAnException() {
+               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage[] = $object;
+       }
+               
+       public function test_AddingAValueOtherThanAnObjectThrowsAnException() {
+               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage[$object] = 'foo';
+       }
+       
+       public function test_IfTheOffsetAndTheValueAreNotEqualAnExceptionIsThrown() {
+               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $object2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage[$object1] = $object2;
+       }       
+       
+       public function test_AnObjectCouldBeSetViaAnOffset() {
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage[$object] = $object;
+               $result = $objectStorage->offsetGet($object);
+               $this->assertEquals($result, $object, 'The retrieved object differs from the attached object.');
+       }
+       
+       public function test_ItCanBeTestedIfTheStorageContainsAnObject() {
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage->attach($object);
+               $result = $objectStorage->contains($object);
+               $this->assertEquals($result, TRUE, 'The method object differs from the attached object.');              
+       }
+       
+       public function test_UnsettingSomethingElseThanAnObjectThrowsAnException() {
+               $this->setExpectedException('Tx_ExtBase_Exception_InvalidArgumentType');
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               // $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               // $objectStorage->offsetSet($object, $object);
+               $objectStorage->offsetUnset('foo');
+       }
+
+       public function test_AnObjectCanBeUnset() {
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage->offsetSet($object, $object);
+               $resultBeforeDetaching = $objectStorage->offsetGet($object);
+               $this->assertEquals($resultBeforeDetaching, $object, 'The object could not be set via offsetSet().');           
+               $objectStorage->offsetUnset($object);
+               $resultAfterDetaching = $objectStorage->offsetGet($object);
+               $this->assertEquals($resultAfterDetaching, NULL, 'The object could not be unsetted.');          
+       }
+
+       public function test_TheStorageCanBeRetrievedAsArray() {
+               $objectStorage = new Tx_ExtBase_Persistence_ObjectStorage();
+               $object1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage->offsetSet($object1, $object1);
+               $object2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $objectStorage->offsetSet($object2, $object2);
+               $result = $objectStorage->toArray();
+               $this->assertEquals(is_array($result), TRUE, 'The result was not an array as expected.');               
+               $this->assertEquals(count($result), 2, 'The retrieved array did not contain two elements.');            
+       }
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Persistence/Repository_testcase.php b/typo3/sysext/extbase/Tests/Persistence/Repository_testcase.php
new file mode 100644 (file)
index 0000000..31b3d2a
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+class Tx_ExtBase_Persistence_Repository_testcase extends Tx_ExtBase_Base_testcase {
+       public function __construct() {
+               require_once(t3lib_extMgm::extPath('blogexample', 'Classes/Domain/Model/BlogRepository.php'));
+       }
+
+       public function test_FindDelegatesToObjectRelationalMapperBuildQueryAndFetch() {
+               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
+               $repository->dataMapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('buildQuery', 'fetch'), array(), '', FALSE);
+               $repository->dataMapper->expects($this->once())
+                       ->method('buildQuery')
+                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('foo'))
+                       ->will($this->returnValue('query'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('query'))
+                       ->will($this->returnValue(array()));
+               
+               $result = $repository->findByConditions('foo');
+               $this->assertEquals(array(), $result);
+       }
+
+       public function test_MagicFindByPropertyUsesGenericFind() {
+               $repository = $this->getMock('Tx_BlogExample_Domain_Model_BlogRepository', array('findByConditions'), array('Tx_BlogExample_Domain_Model_Blog'));
+               $repository->expects($this->once())
+                       ->method('findByConditions')
+                       ->with($this->equalTo(array('name' => 'foo')))
+                       ->will($this->returnValue(array()));
+               
+               $repository->findByName('foo');
+       }
+
+       public function test_MagicFindOneByPropertyUsesGenericFind() {
+               $repository = $this->getMock('TX_Blogexample_Domain_Model_BlogRepository', array('findByConditions'), array('Tx_BlogExample_Domain_Model_Blog'));
+               $repository->expects($this->once())
+                       ->method('findByConditions')
+                       ->with($this->equalTo(array('name' => 'foo')), $this->equalTo(''), $this->equalTo(''), $this->equalTo(1))
+                       ->will($this->returnValue(array()));
+               
+               $repository->findOneByName('foo');
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Persistence/Session_testcase.php b/typo3/sysext/extbase/Tests/Persistence/Session_testcase.php
new file mode 100644 (file)
index 0000000..a4dd861
--- /dev/null
@@ -0,0 +1,224 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+require_once(PATH_tslib . 'class.tslib_content.php');
+
+class Tx_ExtBase_Persistence_Session_testcase extends tx_phpunit_testcase {
+       
+       public function setUp() {
+       }
+       
+       public function test_NewSessionIsEmpty() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_ObjectCanBeRegisteredAsAdded() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerAddedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(1, count($addedObjects), 'The added objects storage holds 0 or more than 1 objects.');
+               $this->assertSame($entity, $addedObjects[0], 'The returned object was not the same as the registered one.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_ObjectCanBeRegisteredAsRemoved() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerRemovedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(1, count($removedObjects), 'The removed objects storage holds 0 or more than 1 objects.');
+               $this->assertSame($entity, $removedObjects[0], 'The returned object was not the same as the registered one.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_ObjectCanBeRegisteredAsReconstituted() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerReconstitutedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(1, count($reconstitutedObjects), 'The reconstituted objects storage holds 0 or more than 1 objects.');
+               $this->assertSame($entity, $reconstitutedObjects[0], 'The returned object was not the same as the registered one.');
+       }
+
+       public function test_ObjectCanBeUnregisteredAsAdded() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerAddedObject($entity);
+               $persistenceSession->unregisterAddedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_ObjectCanBeUnregisteredAsRemoved() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerRemovedObject($entity);
+               $persistenceSession->unregisterRemovedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_ObjectCanBeUnregisteredAsReconstituted() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerReconstitutedObject($entity);
+               $persistenceSession->unregisterReconstitutedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+       public function test_ObjectCanBeRemovedAfterBeingAdded() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerAddedObject($entity);
+               $persistenceSession->registerRemovedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_AnObjectCanBeRemovedAfterBeingAdded() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerAddedObject($entity);
+               $persistenceSession->registerRemovedObject($entity);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_TryingToRegisterReconstitutedObjectsAsAddedResultsInAnException() {
+               $this->setExpectedException('InvalidArgumentException');
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerReconstitutedObject($entity);
+               $persistenceSession->registerAddedObject($entity);
+       }
+
+       public function test_TryingToRegisterAddedObjectsAsReconstitutedResultsInAnException() {
+               $this->setExpectedException('InvalidArgumentException');
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerAddedObject($entity1);
+               $persistenceSession->registerReconstitutedObject($entity1);
+       }
+
+       public function test_SessionCanBeCleared() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $entity2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $entity3 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerAddedObject($entity1);
+               $persistenceSession->registerRemovedObject($entity2);
+               $persistenceSession->registerReconstitutedObject($entity3);
+               $persistenceSession->registerAggregateRootClassName('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->clear();
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+               $aggregateRootClassNames = $persistenceSession->getAggregateRootClassNames();
+
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+               $this->assertEquals(0, count($aggregateRootClassName), 'The aggregate root class name was not empty.');
+       }
+
+       public function test_ObjectCanBeUnregistered() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $entity2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $entity3 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $persistenceSession->registerAddedObject($entity1);
+               $persistenceSession->registerRemovedObject($entity2);
+               $persistenceSession->registerReconstitutedObject($entity3);
+               $persistenceSession->unregisterObject($entity1);
+               $persistenceSession->unregisterObject($entity2);
+               $persistenceSession->unregisterObject($entity3);
+               $addedObjects = $persistenceSession->getAddedObjects();
+               $removedObjects = $persistenceSession->getRemovedObjects();
+               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
+
+               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
+               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
+               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
+       }
+
+       public function test_DirtyEntitiesAreReturned() {
+               $persistenceSession = new Tx_ExtBase_Persistence_Session;
+               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
+               $entity->expects($this->any())
+                       ->method('_isDirty')
+                       ->will($this->returnValue(TRUE));
+               $persistenceSession->registerReconstitutedObject($entity);
+               $dirtyObjects = $persistenceSession->getDirtyObjects();
+               $this->assertEquals(1, count($dirtyObjects), 'There is more than one dirty object.');
+               $this->assertEquals($entity, $dirtyObjects[0], 'The entity doesn\'t equal to the dirty object retrieved from the persistenceSession.');
+       }
+
+       
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Repository_testcase.php b/typo3/sysext/extbase/Tests/Repository_testcase.php
deleted file mode 100644 (file)
index 31b3d2a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christopher Hlubek <hlubek@networkteam.com>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-class Tx_ExtBase_Persistence_Repository_testcase extends Tx_ExtBase_Base_testcase {
-       public function __construct() {
-               require_once(t3lib_extMgm::extPath('blogexample', 'Classes/Domain/Model/BlogRepository.php'));
-       }
-
-       public function test_FindDelegatesToObjectRelationalMapperBuildQueryAndFetch() {
-               $repository = new Tx_BlogExample_Domain_Model_BlogRepository();
-               $repository->dataMapper = $this->getMock('Tx_ExtBase_Persistence_Mapper_ObjectRelationalMapper', array('buildQuery', 'fetch'), array(), '', FALSE);
-               $repository->dataMapper->expects($this->once())
-                       ->method('buildQuery')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('foo'))
-                       ->will($this->returnValue('query'));
-               $repository->dataMapper->expects($this->once())
-                       ->method('fetch')
-                       ->with($this->equalTo('Tx_BlogExample_Domain_Model_Blog'), $this->equalTo('query'))
-                       ->will($this->returnValue(array()));
-               
-               $result = $repository->findByConditions('foo');
-               $this->assertEquals(array(), $result);
-       }
-
-       public function test_MagicFindByPropertyUsesGenericFind() {
-               $repository = $this->getMock('Tx_BlogExample_Domain_Model_BlogRepository', array('findByConditions'), array('Tx_BlogExample_Domain_Model_Blog'));
-               $repository->expects($this->once())
-                       ->method('findByConditions')
-                       ->with($this->equalTo(array('name' => 'foo')))
-                       ->will($this->returnValue(array()));
-               
-               $repository->findByName('foo');
-       }
-
-       public function test_MagicFindOneByPropertyUsesGenericFind() {
-               $repository = $this->getMock('TX_Blogexample_Domain_Model_BlogRepository', array('findByConditions'), array('Tx_BlogExample_Domain_Model_Blog'));
-               $repository->expects($this->once())
-                       ->method('findByConditions')
-                       ->with($this->equalTo(array('name' => 'foo')), $this->equalTo(''), $this->equalTo(''), $this->equalTo(1))
-                       ->will($this->returnValue(array()));
-               
-               $repository->findOneByName('foo');
-       }
-}
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Session_testcase.php b/typo3/sysext/extbase/Tests/Session_testcase.php
deleted file mode 100644 (file)
index a4dd861..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-
-require_once(PATH_tslib . 'class.tslib_content.php');
-
-class Tx_ExtBase_Persistence_Session_testcase extends tx_phpunit_testcase {
-       
-       public function setUp() {
-       }
-       
-       public function test_NewSessionIsEmpty() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_ObjectCanBeRegisteredAsAdded() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerAddedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(1, count($addedObjects), 'The added objects storage holds 0 or more than 1 objects.');
-               $this->assertSame($entity, $addedObjects[0], 'The returned object was not the same as the registered one.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_ObjectCanBeRegisteredAsRemoved() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerRemovedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(1, count($removedObjects), 'The removed objects storage holds 0 or more than 1 objects.');
-               $this->assertSame($entity, $removedObjects[0], 'The returned object was not the same as the registered one.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_ObjectCanBeRegisteredAsReconstituted() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerReconstitutedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(1, count($reconstitutedObjects), 'The reconstituted objects storage holds 0 or more than 1 objects.');
-               $this->assertSame($entity, $reconstitutedObjects[0], 'The returned object was not the same as the registered one.');
-       }
-
-       public function test_ObjectCanBeUnregisteredAsAdded() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerAddedObject($entity);
-               $persistenceSession->unregisterAddedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_ObjectCanBeUnregisteredAsRemoved() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerRemovedObject($entity);
-               $persistenceSession->unregisterRemovedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_ObjectCanBeUnregisteredAsReconstituted() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerReconstitutedObject($entity);
-               $persistenceSession->unregisterReconstitutedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-       public function test_ObjectCanBeRemovedAfterBeingAdded() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerAddedObject($entity);
-               $persistenceSession->registerRemovedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_AnObjectCanBeRemovedAfterBeingAdded() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerAddedObject($entity);
-               $persistenceSession->registerRemovedObject($entity);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_TryingToRegisterReconstitutedObjectsAsAddedResultsInAnException() {
-               $this->setExpectedException('InvalidArgumentException');
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerReconstitutedObject($entity);
-               $persistenceSession->registerAddedObject($entity);
-       }
-
-       public function test_TryingToRegisterAddedObjectsAsReconstitutedResultsInAnException() {
-               $this->setExpectedException('InvalidArgumentException');
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerAddedObject($entity1);
-               $persistenceSession->registerReconstitutedObject($entity1);
-       }
-
-       public function test_SessionCanBeCleared() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $entity2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $entity3 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerAddedObject($entity1);
-               $persistenceSession->registerRemovedObject($entity2);
-               $persistenceSession->registerReconstitutedObject($entity3);
-               $persistenceSession->registerAggregateRootClassName('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->clear();
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-               $aggregateRootClassNames = $persistenceSession->getAggregateRootClassNames();
-
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-               $this->assertEquals(0, count($aggregateRootClassName), 'The aggregate root class name was not empty.');
-       }
-
-       public function test_ObjectCanBeUnregistered() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity1 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $entity2 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $entity3 = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $persistenceSession->registerAddedObject($entity1);
-               $persistenceSession->registerRemovedObject($entity2);
-               $persistenceSession->registerReconstitutedObject($entity3);
-               $persistenceSession->unregisterObject($entity1);
-               $persistenceSession->unregisterObject($entity2);
-               $persistenceSession->unregisterObject($entity3);
-               $addedObjects = $persistenceSession->getAddedObjects();
-               $removedObjects = $persistenceSession->getRemovedObjects();
-               $reconstitutedObjects = $persistenceSession->getReconstitutedObjects();
-
-               $this->assertEquals(0, count($addedObjects), 'The added objects storage was not empty.');
-               $this->assertEquals(0, count($removedObjects), 'The removed objects storage was not empty.');
-               $this->assertEquals(0, count($reconstitutedObjects), 'The reconstituted objects storage was not empty.');
-       }
-
-       public function test_DirtyEntitiesAreReturned() {
-               $persistenceSession = new Tx_ExtBase_Persistence_Session;
-               $entity = $this->getMock('Tx_ExtBase_DomainObject_AbstractEntity');
-               $entity->expects($this->any())
-                       ->method('_isDirty')
-                       ->will($this->returnValue(TRUE));
-               $persistenceSession->registerReconstitutedObject($entity);
-               $dirtyObjects = $persistenceSession->getDirtyObjects();
-               $this->assertEquals(1, count($dirtyObjects), 'There is more than one dirty object.');
-               $this->assertEquals($entity, $dirtyObjects[0], 'The entity doesn\'t equal to the dirty object retrieved from the persistenceSession.');
-       }
-
-       
-}
-?>
\ No newline at end of file