EXTMVC (Patch provided by Christopher Hlubek)
authorJochen Rau <j.rau@web.de>
Tue, 24 Mar 2009 20:57:56 +0000 (20:57 +0000)
committerJochen Rau <j.rau@web.de>
Tue, 24 Mar 2009 20:57:56 +0000 (20:57 +0000)
* Added Base Testcase mit AutoLoader
* Added several test cases
* Added support for RELATION_HAS_ONE
* Added a generic find method with query substitution

typo3/sysext/extbase/Classes/Persistence/Mapper/DataMap.php
typo3/sysext/extbase/Classes/Persistence/Mapper/ObjectRelationalMapper.php
typo3/sysext/extbase/Classes/Persistence/Repository.php
typo3/sysext/extbase/Classes/Persistence/Repository.php.orig [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Tests/Base_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Tests/Repository_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Base_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/DataMap_testcase.php
typo3/sysext/extbase/Tests/Repository_testcase.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Session_testcase.php
typo3/sysext/extbase/class.tx_extmvc_dispatcher.php

index 1818a45..599728f 100644 (file)
@@ -130,14 +130,24 @@ class TX_EXTMVC_Persistence_Mapper_DataMap {
        }
 
        protected function setRelations(TX_EXTMVC_Persistence_Mapper_ColumnMap &$columnMap, $columnConfiguration) {
-               if (array_key_exists('foreign_table', $columnConfiguration['config']) && !array_key_exists('MM', $columnConfiguration['config'])) {
-                       $columnMap->setTypeOfRelation(TX_EXTMVC_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY);
-                       $columnMap->setChildClassName($columnConfiguration['config']['foreign_class']);
-                       $columnMap->setChildTableName($columnConfiguration['config']['foreign_table']);
-                       $columnMap->setChildTableWhere($columnConfiguration['config']['foreign_table_where']);
-                       $columnMap->setChildSortbyFieldName($columnConfiguration['config']['foreign_sortby']);
-                       $columnMap->setParentKeyFieldName($columnConfiguration['config']['foreign_field']);
-                       $columnMap->setParentTableFieldName($columnConfiguration['config']['foreign_table_field']);
+               if (isset($columnConfiguration['config']['foreign_table']) && !isset($columnConfiguration['config']['MM'])) {
+                       if ($columnConfiguration['config']['maxitems'] == 1) {
+                               $columnMap->setTypeOfRelation(TX_EXTMVC_Persistence_Mapper_ColumnMap::RELATION_HAS_ONE);
+                               $columnMap->setChildClassName($columnConfiguration['config']['foreign_class']);
+                               $columnMap->setChildTableName($columnConfiguration['config']['foreign_table']);
+                               $columnMap->setChildTableWhere($columnConfiguration['config']['foreign_table_where']);
+                               $columnMap->setChildSortbyFieldName($columnConfiguration['config']['foreign_sortby']);
+                               $columnMap->setParentKeyFieldName($columnConfiguration['config']['foreign_field']);
+                               $columnMap->setParentTableFieldName($columnConfiguration['config']['foreign_table_field']);                             
+                       } else {
+                               $columnMap->setTypeOfRelation(TX_EXTMVC_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY);
+                               $columnMap->setChildClassName($columnConfiguration['config']['foreign_class']);
+                               $columnMap->setChildTableName($columnConfiguration['config']['foreign_table']);
+                               $columnMap->setChildTableWhere($columnConfiguration['config']['foreign_table_where']);
+                               $columnMap->setChildSortbyFieldName($columnConfiguration['config']['foreign_sortby']);
+                               $columnMap->setParentKeyFieldName($columnConfiguration['config']['foreign_field']);
+                               $columnMap->setParentTableFieldName($columnConfiguration['config']['foreign_table_field']);
+                       }
                } elseif (array_key_exists('MM', $columnConfiguration['config'])) {
                        $columnMap->setTypeOfRelation(TX_EXTMVC_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY);
                        $columnMap->setChildClassName($columnConfiguration['config']['foreign_class']);
index d4cc9e4..aef5335 100644 (file)
@@ -235,7 +235,7 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
                }
 
                unset($row['uid']);
-               // TODO Check if there is a pid field/tstamp field
+
                $row['pid'] = !empty($this->cObj->data['pages']) ? $this->cObj->data['pages'] : $GLOBALS['TSFE']->id;
                $row['tstamp'] = time();
 
index 4838bba..4789b72 100644 (file)
@@ -59,10 +59,13 @@ abstract class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence
         * Constructs a new Repository
         *
         */
-       public function __construct() {
+       public function __construct($aggregateRootClassName = NULL) {
                $this->objects = new TX_EXTMVC_Persistence_ObjectStorage();
                $repositoryClassName = get_class($this);
-               if (substr($repositoryClassName, -10) == 'Repository' && substr($repositoryClassName, -11, 1) != '_') {
+               $repositoryPosition = strrpos($repositoryClassName, 'Repository');
+               if ($aggregateRootClassName != NULL) {
+                       $this->aggregateRootClassName = $aggregateRootClassName;
+               } elseif (substr($repositoryClassName, -10) == 'Repository' && substr($repositoryClassName, -11, 1) != '_') {
                        $this->aggregateRootClassName = substr($repositoryClassName, 0, -10);
                }
                if (empty($this->aggregateRootClassName)) {
@@ -123,6 +126,73 @@ abstract class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence
                }
                throw new TX_EXTMVC_Persistence_Exception_UnsupportedMethod('The method "' . $methodName . '" is not supported by the repository.', 1233180480);
        }
+       
+       
+       /**
+        * Find objects by multiple conditions. Either as SQL parts or query by example.
+        * 
+        * The following condition array would find entities with description like the given keyword and
+        * name equal to "foo".
+        *
+        * <pre>
+        * array(
+        *   array('blog_description LIKE ?', $keword),
+        *   'blogName' => 'Foo'
+        * )
+        * </pre>
+        * 
+        * Note: The SQL part uses the database columns names, the query by example syntax uses
+        * the object property name (camel-cased, without underscore).
+        *
+        * @param array|string $conditions The conditions as an array or SQL string
+        * @param string $groupBy Group by SQL part
+        * @param string $orderBy Order by SQL part
+        * @param string $limit Limit SQL part
+        * @param bool $useEnableFields Wether to automatically restrict the query by enable fields
+        * @return array An array of objects, empty if no objects found
+        *
+        * @todo implement support for SQL LIMIT
+        */
+       public function find($conditions = '', $groupBy = '', $orderBy = '', $limit = '', $useEnableFields = TRUE) {
+               if (is_array($conditions)) {
+                       $whereParts = array();
+                       foreach ($conditions as $key => $condition) {
+                               if (is_array($condition) && isset($condition[0])) {
+                                       $sql = $condition[0];
+                                       for ($i = 1; $i < count($condition); $i++) {
+                                               $markPos = strpos($sql, '?');
+                                               if ($markPos !== FALSE) {
+                                                       $sql = substr($sql, 0, $markPos) . $this->convertValueToQueryParameter($condition[$i]) . substr($sql, $markPos + 1);
+                                               }
+                                       }
+                                       $whereParts[] = '(' . $sql . ')';
+                               } elseif (is_string($key)) {
+                                       if (!is_array($condition)) {
+                                               // TODO substitute key with column name
+                                               $column = $this->dataMapper->getDataMap($this->aggregateRootClassName)->getColumnMap($key)->getPropertyName();
+                                               $sql = $column . ' = ' . $this->convertValueToQueryParameter($condition);
+                                       }
+                                       $whereParts[] = '(' . $sql . ')';
+                               }
+                       }
+                       $where = implode(' AND ', $whereParts);
+               } elseif (is_string($conditions)) {
+                       $where = $conditions;
+               }
+               
+               return $this->dataMapper->fetch($this->aggregateRootClassName, $where, $groupBy, $orderBy, $limit, $useEnableFields);
+       }
+
+       protected function convertValueToQueryParameter($value) {
+               if (is_bool($value)) {
+                       $parameter = $value ? 1 : 0;
+               } elseif ($value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
+                       $parameter = $value->getUid();
+               } else {
+                       $parameter = (string)$value;
+               }
+               return $GLOBALS['TYPO3_DB']->fullQuoteStr($parameter, '');
+       }
 
        /**
         * Returns all objects of this repository
@@ -130,7 +200,7 @@ abstract class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence
         * @return array An array of objects, empty if no objects found
         */
        public function findAll() {
-               return $this->findWhere($this->aggregateRootClassName);
+               return $this->find();
        }
 
        /**
@@ -141,26 +211,7 @@ abstract class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence
         * @return array The result
         */
        protected function findByProperty($propertyName, $value) {
-               // TODO implement support for SQL LIMIT
-               if ($value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
-                       $where = $propertyName . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value->getUid(), '');
-               } else {
-                       $where = $propertyName . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, '');
-               }
-               return $this->findWhere($this->aggregateRootClassName, $where);
+               return $this->find(array($propertyName => $value));
        }
-
-       /**
-        * A generic find where method
-        *
-        * @param string $className The class name
-        * @param string $arguments The WHERE statement
-        * @return void
-        */
-       public function findWhere($className, $where = '1=1', $groupBy = '', $orderBy = '', $limit = '', $useEnableFields = TRUE) {
-               // TODO check for aggregateRootclassName
-               return $this->dataMapper->fetch($className, $where, $groupBy, $orderBy, $limit);
-       }
-
 }
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/Repository.php.orig b/typo3/sysext/extbase/Classes/Persistence/Repository.php.orig
new file mode 100644 (file)
index 0000000..4838bba
--- /dev/null
@@ -0,0 +1,166 @@
+<?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_t3lib . 'interfaces/interface.t3lib_singleton.php');
+require_once(PATH_tslib . 'class.tslib_content.php');
+
+/**
+ * The base repository - will usually be extended by a more concrete repository.
+ *
+ * @package TYPO3
+ * @subpackage extmvc
+ * @version $ID:$
+ */
+abstract class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_RepositoryInterface, t3lib_Singleton {
+
+       /**
+        * Class Name of the aggregate root
+        *
+        * @var string
+        */
+       protected $aggregateRootClassName;
+
+       /**
+        * Objects of this repository
+        *
+        * @var TX_EXTMVC_Persistence_ObjectStorage
+        */
+       protected $objects;
+
+       /**
+        * Contains the persistence session of the current extension
+        *
+        * @var TX_EXTMVC_Persistence_Session
+        */
+       protected $persistenceSession;
+
+       /**
+        * Constructs a new Repository
+        *
+        */
+       public function __construct() {
+               $this->objects = new TX_EXTMVC_Persistence_ObjectStorage();
+               $repositoryClassName = get_class($this);
+               if (substr($repositoryClassName, -10) == 'Repository' && substr($repositoryClassName, -11, 1) != '_') {
+                       $this->aggregateRootClassName = substr($repositoryClassName, 0, -10);
+               }
+               if (empty($this->aggregateRootClassName)) {
+                       throw new TX_EXTMVC_Exception('The domain repository wasn\'t able to resolve the aggregate root class to manage.', 1237897039);
+               }
+               if (!in_array('TX_EXTMVC_DomainObject_DomainObjectInterface', class_implements($this->aggregateRootClassName))) {
+                       throw new TX_EXTMVC_Exception('The domain repository tried to manage objects which are not implementing the TX_EXTMVC_DomainObject_DomainObjectInterface.', 1237897039);
+               }
+               $this->dataMapper = t3lib_div::makeInstance('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper'); // singleton
+               $this->persistenceSession = t3lib_div::makeInstance('TX_EXTMVC_Persistence_Session'); // singleton
+               $this->persistenceSession->registerAggregateRootClassName($this->aggregateRootClassName);
+       }
+
+       /**
+        * Adds an object to this repository
+        *
+        * @param object $object The object to add
+        * @return void
+        */
+       public function add($object) {
+               if (!($object instanceof $this->aggregateRootClassName)) throw new TX_EXTMVC_Persistence_Exception_InvalidClass('The class "' . get_class($object) . '" is not supported by the repository.');
+               $this->objects->attach($object);
+               $this->persistenceSession->registerAddedObject($object);
+       }
+
+       /**
+        * Removes an object from this repository.
+        *
+        * @param object $object The object to remove
+        * @return void
+        */
+       public function remove($object) {
+               if (!($object instanceof $this->aggregateRootClassName)) throw new TX_EXTMVC_Persistence_Exception_InvalidClass('The class "' . get_class($object) . '" is not supported by the repository.');
+               $this->objects->detach($object);
+               $this->persistenceSession->registerRemovedObject($object);
+       }
+
+       /**
+        * Dispatches magic methods (findBy[Property]())
+        *
+        * @param string $methodName The name of the magic method
+        * @param string $arguments The arguments of the magic method
+        * @throws TX_EXTMVC_Persistence_Exception_UnsupportedMethod
+        * @return void
+        */
+       public function __call($methodName, $arguments) {
+               if (substr($methodName, 0, 6) === 'findBy' && strlen($methodName) > 7) {
+                       $propertyName = TX_EXTMVC_Utility_Strings::lowercaseFirst(substr($methodName,6));
+                       return $this->findByProperty($propertyName, $arguments[0]);
+               } elseif (substr($methodName, 0, 9) === 'findOneBy' && strlen($methodName) > 10) {
+                       $propertyName = TX_EXTMVC_Utility_Strings::lowercaseFirst(substr($methodName,9));
+                       $result = $this->findByProperty($propertyName, $arguments[0]);
+                       if (empty($result)) {
+                               return FALSE;
+                       } else {
+                               return $result[0]; // TODO Implement LIMIT
+                       }
+               }
+               throw new TX_EXTMVC_Persistence_Exception_UnsupportedMethod('The method "' . $methodName . '" is not supported by the repository.', 1233180480);
+       }
+
+       /**
+        * Returns all objects of this repository
+        *
+        * @return array An array of objects, empty if no objects found
+        */
+       public function findAll() {
+               return $this->findWhere($this->aggregateRootClassName);
+       }
+
+       /**
+        * Finds objects matching 'property=xyz'
+        *
+        * @param string $propertyName The name of the property (will be checked by a white list)
+        * @param string $arguments The arguments of the magic findBy method
+        * @return array The result
+        */
+       protected function findByProperty($propertyName, $value) {
+               // TODO implement support for SQL LIMIT
+               if ($value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
+                       $where = $propertyName . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value->getUid(), '');
+               } else {
+                       $where = $propertyName . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($value, '');
+               }
+               return $this->findWhere($this->aggregateRootClassName, $where);
+       }
+
+       /**
+        * A generic find where method
+        *
+        * @param string $className The class name
+        * @param string $arguments The WHERE statement
+        * @return void
+        */
+       public function findWhere($className, $where = '1=1', $groupBy = '', $orderBy = '', $limit = '', $useEnableFields = TRUE) {
+               // TODO check for aggregateRootclassName
+               return $this->dataMapper->fetch($className, $where, $groupBy, $orderBy, $limit);
+       }
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/Tests/Base_testcase.php b/typo3/sysext/extbase/Classes/Persistence/Tests/Base_testcase.php
new file mode 100644 (file)
index 0000000..69ef192
--- /dev/null
@@ -0,0 +1,111 @@
+<?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!
+***************************************************************/
+
+require_once(t3lib_extMgm::extPath('extmvc', 'class.tx_extmvc_dispatcher.php'));
+
+/**
+ * Base testcase for the extmvc extension. Currently it only registers the autoloader.
+ */
+abstract class TX_EXTMVC_Base_testcase extends tx_phpunit_testcase {
+       public function __construct() {
+               parent::__construct();
+               $dispatcher = t3lib_div::makeInstance('TX_EXTMVC_Dispatcher');
+               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
+       }
+}
+?>
+<?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!
+***************************************************************/
+
+require_once(t3lib_extMgm::extPath('extmvc', 'class.tx_extmvc_dispatcher.php'));
+
+/**
+ * Base testcase for the extmvc extension. Currently it only registers the autoloader.
+ */
+abstract class TX_EXTMVC_Base_testcase extends tx_phpunit_testcase {
+       public function __construct() {
+               parent::__construct();
+               $dispatcher = t3lib_div::makeInstance('TX_EXTMVC_Dispatcher');
+               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
+       }
+}
+?>
+<?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!
+***************************************************************/
+
+require_once(t3lib_extMgm::extPath('extmvc', 'class.tx_extmvc_dispatcher.php'));
+
+/**
+ * Base testcase for the extmvc extension. Currently it only registers the autoloader.
+ */
+abstract class TX_EXTMVC_Base_testcase extends tx_phpunit_testcase {
+       public function __construct() {
+               parent::__construct();
+               $dispatcher = t3lib_div::makeInstance('TX_EXTMVC_Dispatcher');
+               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/Tests/Repository_testcase.php b/typo3/sysext/extbase/Classes/Persistence/Tests/Repository_testcase.php
new file mode 100644 (file)
index 0000000..6c7bbd0
--- /dev/null
@@ -0,0 +1,309 @@
+<?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!
+***************************************************************/
+
+require_once('Base_testcase.php');
+
+class TX_EXTMVC_Persistence_Repository_testcase extends TX_EXTMVC_Base_testcase {
+
+       public function __construct() {
+               require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/BlogRepository.php');
+       }
+
+       public function setUp() {
+               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
+               $GLOBALS['TSFE']->expects($this->any())
+                       ->method('includeTCA')
+                       ->will($this->returnValue(NULL));
+               
+               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
+       }
+
+       public function test_FindByConditionWithPlaceholders() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)'));
+               
+               $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"'));
+
+               $GLOBALS['TYPO3_DB']->expects($this->at(2))
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
+                       array('hidden = ?', FALSE)
+                       ));
+       }
+
+       public function test_FindByConditionWithExample() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(blog_name = "foo") AND (hidden = 0)'));
+               
+               $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('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       'blogName' => 'foo',
+                       'hidden' => FALSE
+               ));
+       }
+       
+       public function test_MagicFindByPropertyUsesGenericFind() {
+               $repository = $this->getMock('TX_Blogexample_Domain_BlogRepository', array('find'), array('TX_Blogexample_Domain_Blog'));
+               $repository->expects($this->once())
+                       ->method('find')
+                       ->with($this->equalTo(array('name' => 'foo')))
+                       ->will($this->returnValue(array()));
+               
+               $repository->findByName('foo');
+       }
+}
+?>
+<?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!
+***************************************************************/
+
+require_once('Base_testcase.php');
+
+class TX_EXTMVC_Persistence_Repository_testcase extends TX_EXTMVC_Base_testcase {
+
+       public function __construct() {
+               require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/BlogRepository.php');
+       }
+
+       public function setUp() {
+               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
+               $GLOBALS['TSFE']->expects($this->any())
+                       ->method('includeTCA')
+                       ->will($this->returnValue(NULL));
+               
+               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
+       }
+
+       public function test_FindByConditionWithPlaceholders() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)'));
+               
+               $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"'));
+
+               $GLOBALS['TYPO3_DB']->expects($this->at(2))
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
+                       array('hidden = ?', FALSE)
+                       ));
+       }
+
+       public function test_FindByConditionWithExample() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(blog_name = "foo") AND (hidden = 0)'));
+               
+               $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('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       'blogName' => 'foo',
+                       'hidden' => FALSE
+               ));
+       }
+       
+       public function test_MagicFindByPropertyUsesGenericFind() {
+               $repository = $this->getMock('TX_Blogexample_Domain_BlogRepository', array('find'), array('TX_Blogexample_Domain_Blog'));
+               $repository->expects($this->once())
+                       ->method('find')
+                       ->with($this->equalTo(array('name' => 'foo')))
+                       ->will($this->returnValue(array()));
+               
+               $repository->findByName('foo');
+       }
+}
+?>
+<?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!
+***************************************************************/
+
+require_once('Base_testcase.php');
+
+class TX_EXTMVC_Persistence_Repository_testcase extends TX_EXTMVC_Base_testcase {
+
+       public function __construct() {
+               require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/BlogRepository.php');
+       }
+
+       public function setUp() {
+               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
+               $GLOBALS['TSFE']->expects($this->any())
+                       ->method('includeTCA')
+                       ->will($this->returnValue(NULL));
+               
+               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
+       }
+
+       public function test_FindByConditionWithPlaceholders() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)'));
+               
+               $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"'));
+
+               $GLOBALS['TYPO3_DB']->expects($this->at(2))
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
+                       array('hidden = ?', FALSE)
+                       ));
+       }
+
+       public function test_FindByConditionWithExample() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(blog_name = "foo") AND (hidden = 0)'));
+               
+               $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('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       'blogName' => 'foo',
+                       'hidden' => FALSE
+               ));
+       }
+       
+       public function test_MagicFindByPropertyUsesGenericFind() {
+               $repository = $this->getMock('TX_Blogexample_Domain_BlogRepository', array('find'), array('TX_Blogexample_Domain_Blog'));
+               $repository->expects($this->once())
+                       ->method('find')
+                       ->with($this->equalTo(array('name' => 'foo')))
+                       ->will($this->returnValue(array()));
+               
+               $repository->findByName('foo');
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Base_testcase.php b/typo3/sysext/extbase/Tests/Base_testcase.php
new file mode 100644 (file)
index 0000000..6d4e1d6
--- /dev/null
@@ -0,0 +1,37 @@
+<?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!
+***************************************************************/
+
+require_once(t3lib_extMgm::extPath('extmvc', 'class.tx_extmvc_dispatcher.php'));
+
+/**
+ * Base testcase for the extmvc extension. Currently it only registers the autoloader.
+ */
+abstract class TX_EXTMVC_Base_testcase extends tx_phpunit_testcase {
+       public function __construct() {
+               parent::__construct();
+               $dispatcher = t3lib_div::makeInstance('TX_EXTMVC_Dispatcher');
+               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
+       }
+}
+?>
\ No newline at end of file
index 86f281e..5f489b0 100644 (file)
 ***************************************************************/
 
 require_once(PATH_tslib . 'class.tslib_content.php');
-require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/TX_Blogexample_Domain_Blog.php');
 
-class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends tx_phpunit_testcase {
+require_once('Base_testcase.php');
+
+class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends TX_EXTMVC_Base_testcase {
        
        public function setUp() {
+               require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/Blog.php');
+       
                $GLOBALS['TSFE']->fe_user = $this->getMock('tslib_feUserAuth');
                $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
                $this->setupTca();
@@ -118,6 +121,16 @@ class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends tx_phpunit_testcase
                                                ),
                                        )
                                ),
+                               'author' => array(
+                                       'exclude' => 1,
+                                       'label'   => 'LLL:EXT:blogexample/Resources/Language/locallang_db.xml:tx_blogexample_domain_blog.author',
+                                       'config' => array(
+                                               'type' => 'select',
+                                               'foreign_class' => 'TX_Blogexample_Domain_Author',
+                                               'foreign_table' => 'tx_blogexample_domain_author',
+                                               'maxitems' => 1,
+                                       )
+                               ),
                        ),
                        'types' => array(
                                '1' => array('showitem' => 'hidden, name, description, logo, posts')
@@ -132,7 +145,7 @@ class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends tx_phpunit_testcase
                $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
                $dataMap->initialize();
                $columnMaps = $dataMap->getColumnMaps();
-               $this->assertEquals(11, count($columnMaps), 'The data map was not initialized (wrong number of column maps set).');
+               $this->assertEquals(12, count($columnMaps), 'The data map was not initialized (wrong number of column maps set).');
        }
        
        public function test_DeletedColumnNameCanBeResolved() {
@@ -147,7 +160,7 @@ class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends tx_phpunit_testcase
                $this->assertEquals($hiddenColumnName, 'hidden', 'The hidden column name could not be resolved.');
        }
        
-       public function test_CloumnCanBeAdded() {
+       public function test_ColumnCanBeAdded() {
                $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
                $dataMap->addColumn('test_column');
                $columnMaps = $dataMap->getColumnMaps();
@@ -155,7 +168,7 @@ class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends tx_phpunit_testcase
                $this->assertType('TX_EXTMVC_Persistence_Mapper_ColumnMap', $columnMap, 'The column could not be added.');
        }
        
-       public function test_CloumnListCanBeRetrieved() {
+       public function test_ColumnListCanBeRetrieved() {
                $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
                $dataMap->addColumn('column1');
                $dataMap->addColumn('column2');
@@ -172,5 +185,16 @@ class TX_EXTMVC_Persistence_Mapper_DataMap_testcase extends tx_phpunit_testcase
                $this->assertFalse($dataMap->isPersistableProperty('unconfiguredProperty'), 'The unpersistable property was marked asersistable.');
        }
        
+       public function test_HasManyColumnIsRegisteredForForeignTable() {
+               $dataMap = new TX_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
+               $dataMap->initialize();
+               $this->assertEquals(TX_EXTMVC_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_EXTMVC_Persistence_Mapper_DataMap('TX_Blogexample_Domain_Blog');
+               $dataMap->initialize();
+               $this->assertEquals(TX_EXTMVC_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/Repository_testcase.php b/typo3/sysext/extbase/Tests/Repository_testcase.php
new file mode 100644 (file)
index 0000000..5a074bc
--- /dev/null
@@ -0,0 +1,103 @@
+<?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!
+***************************************************************/
+
+require_once('Base_testcase.php');
+
+class TX_EXTMVC_Persistence_Repository_testcase extends TX_EXTMVC_Base_testcase {
+
+       public function __construct() {
+               require_once(t3lib_extMgm::extPath('blogexample') . 'Classes/Domain/BlogRepository.php');
+       }
+
+       public function setUp() {
+               $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array('includeTCA'));
+               $GLOBALS['TSFE']->expects($this->any())
+                       ->method('includeTCA')
+                       ->will($this->returnValue(NULL));
+               
+               $GLOBALS['TYPO3_DB'] = $this->getMock('tslib_DB', array('fullQuoteStr'));
+       }
+
+       public function test_FindByConditionWithPlaceholders() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(name LIKE "foo" OR name LIKE "bar") AND (hidden = 0)'));
+               
+               $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"'));
+
+               $GLOBALS['TYPO3_DB']->expects($this->at(2))
+                       ->method('fullQuoteStr')
+                       ->with($this->equalTo('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       array('name LIKE ? OR name LIKE ?', 'foo', 'bar'),
+                       array('hidden = ?', FALSE)
+                       ));
+       }
+
+       public function test_FindByConditionWithExample() {
+               $repository = new TX_Blogexample_Domain_BlogRepository();
+               $repository->dataMapper = $this->getMock('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper', array('fetch'));
+               $repository->dataMapper->expects($this->once())
+                       ->method('fetch')
+                       ->with($this->equalTo('TX_Blogexample_Domain_Blog'), $this->equalTo('(blog_name = "foo") AND (hidden = 0)'));
+               
+               $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('0'))
+                       ->will($this->returnValue('0'));
+               
+               $repository->find(array(
+                       'blogName' => 'foo',
+                       'hidden' => FALSE
+               ));
+       }
+       
+       public function test_MagicFindByPropertyUsesGenericFind() {
+               $repository = $this->getMock('TX_Blogexample_Domain_BlogRepository', array('find'), array('TX_Blogexample_Domain_Blog'));
+               $repository->expects($this->once())
+                       ->method('find')
+                       ->with($this->equalTo(array('name' => 'foo')))
+                       ->will($this->returnValue(array()));
+               
+               $repository->findByName('foo');
+       }
+}
+?>
\ No newline at end of file
index 72ce0de..470e64a 100644 (file)
@@ -41,7 +41,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_ObjectCanBeRegisteredAsAdded() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerAddedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
                $removedObjects = $persistenceSession->getRemovedObjects();
@@ -55,7 +55,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_ObjectCanBeRegisteredAsRemoved() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerRemovedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
                $removedObjects = $persistenceSession->getRemovedObjects();
@@ -69,7 +69,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_ObjectCanBeRegisteredAsReconstituted() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerReconstitutedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
                $removedObjects = $persistenceSession->getRemovedObjects();
@@ -83,7 +83,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_ObjectCanBeUnregisteredAsAdded() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerAddedObject($entity);
                $persistenceSession->unregisterAddedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
@@ -97,7 +97,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_ObjectCanBeUnregisteredAsRemoved() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerRemovedObject($entity);
                $persistenceSession->unregisterRemovedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
@@ -111,7 +111,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_ObjectCanBeUnregisteredAsReconstituted() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerReconstitutedObject($entity);
                $persistenceSession->unregisterReconstitutedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
@@ -124,7 +124,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
        }
        public function test_ObjectCanBeRemovedAfterBeingAdded() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerAddedObject($entity);
                $persistenceSession->registerRemovedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
@@ -138,7 +138,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_AnObjectCanBeRemovedAfterBeingAdded() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerAddedObject($entity);
                $persistenceSession->registerRemovedObject($entity);
                $addedObjects = $persistenceSession->getAddedObjects();
@@ -153,7 +153,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
        public function test_TryingToRegisterReconstitutedObjectsAsAddedResultsInAnException() {
                $this->setExpectedException('InvalidArgumentException');
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerReconstitutedObject($entity);
                $persistenceSession->registerAddedObject($entity);
        }
@@ -161,20 +161,20 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
        public function test_TryingToRegisterAddedObjectsAsReconstitutedResultsInAnException() {
                $this->setExpectedException('InvalidArgumentException');
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity1 = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity1 = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerAddedObject($entity1);
                $persistenceSession->registerReconstitutedObject($entity1);
        }
 
        public function test_SessionCanBeCleared() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity1 = $this->getMock('TX_EXTMVC_DomainObject_Entity');
-               $entity2 = $this->getMock('TX_EXTMVC_DomainObject_Entity');
-               $entity3 = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity1 = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
+               $entity2 = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
+               $entity3 = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerAddedObject($entity1);
                $persistenceSession->registerRemovedObject($entity2);
                $persistenceSession->registerReconstitutedObject($entity3);
-               $persistenceSession->registerAggregateRootClassName('TX_EXTMVC_DomainObject_Entity');
+               $persistenceSession->registerAggregateRootClassName('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->clear();
                $addedObjects = $persistenceSession->getAddedObjects();
                $removedObjects = $persistenceSession->getRemovedObjects();
@@ -189,9 +189,9 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_ObjectCanBeUnregistered() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity1 = $this->getMock('TX_EXTMVC_DomainObject_Entity');
-               $entity2 = $this->getMock('TX_EXTMVC_DomainObject_Entity');
-               $entity3 = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity1 = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
+               $entity2 = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
+               $entity3 = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $persistenceSession->registerAddedObject($entity1);
                $persistenceSession->registerRemovedObject($entity2);
                $persistenceSession->registerReconstitutedObject($entity3);
@@ -209,7 +209,7 @@ class TX_EXTMVC_Persistence_Session_testcase extends tx_phpunit_testcase {
 
        public function test_DirtyEntitiesAreReturned() {
                $persistenceSession = new TX_EXTMVC_Persistence_Session;
-               $entity = $this->getMock('TX_EXTMVC_DomainObject_Entity');
+               $entity = $this->getMock('TX_EXTMVC_DomainObject_AbstractEntity');
                $entity->expects($this->any())
                        ->method('_isDirty')
                        ->will($this->returnValue(TRUE));
index 6ab4691..397c581 100644 (file)
@@ -160,7 +160,7 @@ class TX_EXTMVC_Dispatcher {
         * @return void
         */
        // TODO Remove autoloader as soon as we do not need it anymore
-       protected function autoLoadClasses($className) {
+       public function autoLoadClasses($className) {
                if (empty($this->registeredClassNames[$className])) {
                        $classNameParts = explode('_', $className);
                        if ($classNameParts[0] === 'ux') {