Extbase:
authorJochen Rau <j.rau@web.de>
Fri, 15 May 2009 11:20:27 +0000 (11:20 +0000)
committerJochen Rau <j.rau@web.de>
Fri, 15 May 2009 11:20:27 +0000 (11:20 +0000)
* Changed naming $pluginKey to $pluginName
* Deleted patches from the Documentation folder
* Removed spl_autoload_register() from the BaseTestcase
* Taken a few more steps towards the implementation of a Query object

17 files changed:
typo3/sysext/extbase/Classes/MVC/Request.php
typo3/sysext/extbase/Classes/MVC/View/Helper/URIHelper.php
typo3/sysext/extbase/Classes/MVC/Web/RequestBuilder.php
typo3/sysext/extbase/Classes/Persistence/ConstraintInterface.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMap.php
typo3/sysext/extbase/Classes/Persistence/Mapper/ObjectRelationalMapper.php
typo3/sysext/extbase/Classes/Persistence/Query.php
typo3/sysext/extbase/Classes/Persistence/QueryFactory.php
typo3/sysext/extbase/Classes/Persistence/QueryInterface.php
typo3/sysext/extbase/Classes/Persistence/RawSqlConstraint.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/Repository.php
typo3/sysext/extbase/Classes/Persistence/SqlConstraint.php [new file with mode: 0644]
typo3/sysext/extbase/Documentation/t3lib_extMgm_addExtbasePlugin.diff [deleted file]
typo3/sysext/extbase/Documentation/t3lib_extMgm_testcase.php [deleted file]
typo3/sysext/extbase/Tests/Base_testcase.php
typo3/sysext/extbase/Tests/MVC/Web/RequestBuilder_testcase.php
typo3/sysext/extbase/Tests/Persistence/Query_testcase.php

index 1f3d4b1..e1992f0 100644 (file)
@@ -49,7 +49,7 @@ class Tx_Extbase_MVC_Request {
        /**
         * @var string Key of the plugin which identifies the plugin. It must be a string containing [a-z0-9]
         */
-       protected $pluginKey = '';
+       protected $pluginName = '';
 
        /**
         * @var string Name of the extension which is supposed to handle this request. This is the extension name converted to UpperCamelCase
@@ -187,9 +187,9 @@ class Tx_Extbase_MVC_Request {
         * @param string $extensionName The plugin key.
         * @return void
         */
-       public function setPluginKey($pluginKey = NULL) {
-               if ($pluginKey !== NULL) {
-                       $this->pluginKey = $pluginKey;
+       public function setPluginKey($pluginName = NULL) {
+               if ($pluginName !== NULL) {
+                       $this->pluginName = $pluginName;
                }
        }
 
@@ -199,7 +199,7 @@ class Tx_Extbase_MVC_Request {
         * @return string The plugin key
         */
        public function getPluginKey() {
-               return $this->pluginKey;
+               return $this->pluginName;
        }
 
        /**
index c13b6de..ceb70a8 100644 (file)
@@ -92,7 +92,7 @@ class Tx_Extbase_MVC_View_Helper_URIHelper extends Tx_Extbase_MVC_View_Helper_Ab
                }
                $typolinkConfiguration['additionalParams'] = '';
                if (count($arguments) > 0) {
-                       $typolinkConfiguration['additionalParams'] .= '&' . http_build_query($arguments);
+                       $typolinkConfiguration['additionalParams'] .= '&' . http_build_query($arguments); // FIXME escaping is broken; example "'"
                        if (!isset($options['no_cache'])) {
                                $typolinkConfiguration['useCacheHash'] = 1;
                        }
index aa5332a..52185c6 100755 (executable)
@@ -38,7 +38,7 @@ class Tx_Extbase_MVC_Web_RequestBuilder {
         *
         * @var string
         **/
-       protected $pluginKey = 'plugin';
+       protected $pluginName = 'plugin';
        
        /**
         * The name of the extension (in UpperCamelCase)
@@ -69,8 +69,8 @@ class Tx_Extbase_MVC_Web_RequestBuilder {
        protected $allowedControllerActions;
        
        public function initialize($configuration) {
-               if (!empty($configuration['pluginKey'])) {
-                       $this->pluginKey = $configuration['pluginKey'];
+               if (!empty($configuration['pluginName'])) {
+                       $this->pluginName = $configuration['pluginName'];
                }
                if (!empty($configuration['extensionName'])) {
                        $this->extensionName = $configuration['extensionName'];
@@ -105,7 +105,7 @@ class Tx_Extbase_MVC_Web_RequestBuilder {
         * @return Tx_Extbase_MVC_Web_Request The web request as an object
         */
        public function build() {
-               $parameters = t3lib_div::_GET('tx_' . strtolower($this->extensionName) . '_' . strtolower($this->pluginKey));
+               $parameters = t3lib_div::_GET('tx_' . strtolower($this->extensionName) . '_' . strtolower($this->pluginName));
                if (is_string($parameters['controller']) && array_key_exists($parameters['controller'], $this->allowedControllerActions)) {
                        $controllerName = filter_var($parameters['controller'], FILTER_SANITIZE_STRING);
                        $allowedActions = $this->allowedControllerActions[$controllerName];
@@ -120,14 +120,14 @@ class Tx_Extbase_MVC_Web_RequestBuilder {
                }
 
                $request = t3lib_div::makeInstance('Tx_Extbase_MVC_Web_Request');
-               $request->setPluginKey($this->pluginKey);
+               $request->setPluginKey($this->pluginName);
                $request->setControllerExtensionName($this->extensionName);
                $request->setControllerName($controllerName);
                $request->setControllerActionName($actionName);
                $request->setRequestURI(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
                $request->setBaseURI(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
                $request->setMethod((isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : NULL);
-               $GET = t3lib_div::_GET('tx_' . strtolower($this->extensionName) . '_' . strtolower($this->pluginKey));
+               $GET = t3lib_div::_GET('tx_' . strtolower($this->extensionName) . '_' . strtolower($this->pluginName));
                if (is_array($GET)) {
                        foreach ($GET as $key => $value) {
                                $request->setArgument($key, $value);
diff --git a/typo3/sysext/extbase/Classes/Persistence/ConstraintInterface.php b/typo3/sysext/extbase/Classes/Persistence/ConstraintInterface.php
new file mode 100644 (file)
index 0000000..3f43b84
--- /dev/null
@@ -0,0 +1,36 @@
+<?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!
+***************************************************************/
+
+/**
+ * The interface for constraints
+ *
+ * @package TYPO3
+ * @subpackage Extbase
+ * @version $Id: $
+ * @scope prototype
+ */
+interface Tx_Extbase_Persistence_ConstraintInterface {
+}
+
+?>
\ No newline at end of file
index ea62936..6487f06 100644 (file)
@@ -122,6 +122,7 @@ class Tx_Extbase_Persistence_Mapper_DataMap {
                $this->addCommonColumns();
                if (is_array($columns)) {
                        foreach ($columns as $columnName => $columnConfiguration) {
+                               // TODO convert underscore column names to lowercamelcase
                                $columnMap = new Tx_Extbase_Persistence_Mapper_ColumnMap($columnName, $this);
                                $this->setTypeOfValue($columnMap, $columnConfiguration);
                                // TODO support for IRRE
index b242ad8..8d74bf1 100644 (file)
@@ -87,6 +87,7 @@ class Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper implements Tx_Extbase
         * Constructs a new mapper
         *
         */
+       // TODO Interface for database handle
        public function __construct(t3lib_DB $persistenceBackend = NULL) {
                $this->persistenceBackend = $persistenceBackend !== NULL ? $persistenceBackend : $GLOBALS['TYPO3_DB'];
                $this->referenceIndex = t3lib_div::makeInstance('t3lib_refindex');
index 9ff4f19..75c2881 100644 (file)
@@ -46,39 +46,9 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @var Tx_Extbase_Persistence_Session
         */
        protected $persistenceSession;
-       
-       /**
-        * @var string
-        */
-       protected $where;
-
-       /**
-        * @var string
-        */
-       protected $groupBy;
-
-       /**
-        * @var string
-        */
-       protected $orderBy;
-
-       /**
-        * @var integer
-        */
-       protected $limit;
-
-       /**
-        * @var integer
-        */
-       protected $offset;
-       
-       /**
-        * @var boolean
-        */
-       protected $useEnableFields = TRUE;
-       
+               
        /**
-        * @var mixed
+        * @var Tx_Extbase_Persistence_ConstraintInterface
         */
        protected $constraint;
 
@@ -92,6 +62,16 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
        }
 
        /**
+        * Injects the persistence backend to fetch the data from
+        *
+        * @param t3lib_DB $persistenceBackend
+        * @return void
+        */
+       public function injectPersistenceBackend(t3lib_DB $persistenceBackend) {
+               $this->persistenceBackend = $persistenceBackend;
+       }
+
+       /**
         * Injects the DataMapper to map nodes to objects
         *
         * @param Tx_Extbase_Persistence_DataMapperInterface $dataMapper
@@ -107,172 +87,67 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return array The query result as an array of objects
         */
        public function execute() {
-               $this->where = $this->generateWhereClause($this->dataMapper->getDataMap($this->className), $this->constraint);
-               $rows = $this->dataMapper->fetch(
-                       $this->className,
-                       $this->where,
-                       $this->from,
-                       $this->groupBy,
-                       $this->orderBy,
-                       $this->limit,
-                       $this->useEnableFields
+               $statement = $constraint->getStatement();
+               $res = $this->database->exec_SELECTquery(
+                       '*',
+                       $from,
+                       $where . $enableFields,
+                       $groupBy,
+                       $orderBy,
+                       $limit
                        );
-               return $this->dataMapper->map($rows);
+
+               if ($res) {
+                       $fieldMap = $this->getFieldMapFromResult($res);
+                       $rows = $this->getRowsFromResult($dataMap->getTableName(), $res);
+               }
+
+               $objects = array();
+               if (is_array($rows)) {
+                       if (count($rows) > 0) {
+                               $objects = $this->dataMapper->reconstituteObjects($dataMap, $fieldMap, $rows);
+                       }
+               }
+               return $objects;
        }
        
        /**
         * The constraint used to limit the result set
         *
-        * @param mixed $constraint Some constraint, depending on the backend
+        * @param Tx_Extbase_Persistence_ConstraintInterface $constraint Some constraint, depending on the backend
         * @return Tx_Extbase_Persistence_QueryInterface
         */
-       public function matching($constraint) {
+       public function matching(Tx_Extbase_Persistence_ConstraintInterface $constraint) {
                $this->constraint = $constraint;
                return $this;
        }
        
-       
-       /**
-        * The following condition array would find entities with description like the given keyword and
-        * name equal to "foo".
-        *
-        * <pre>
-        * array(
-        *              array('blog_description LIKE ?', $keyword),
-        *              '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 Tx_Extbase_Persistence_Mapper_DataMap $dataMap The data map
-        * @return string The query where part for the class and given conditions
-        */
-       public function generateWhereClause(Tx_Extbase_Persistence_Mapper_DataMap $dataMap, $constraint) {
-               $where = '';
-               if (is_array($constraint)) {
-                       $whereParts = array();
-                       foreach ($constraint as $key => $condition) {
-                               if (is_array($condition) && isset($condition[0])) {
-                                       $sql = $this->replacePlaceholders($dataMap, $condition[0], array_slice($condition, 1));
-                                       $whereParts[] = '(' . $sql . ')';
-                               } elseif (is_string($key)) {
-                                       $sql = $this->generateWhereClauseByExample($dataMap, $key, $condition);
-                                       if (strlen($sql) > 0) {
-                                               $whereParts[] = '(' . $sql . ')';
-                                       }
-                               }
+       protected function getRowsFromResult($tableName, $res) {
+               $rows = array();
+               while ($row = $this->persistenceBackend->sql_fetch_assoc($res)) {
+                       $row = $this->doLanguageAndWorkspaceOverlay($tableName, $row);
+                       if (is_array($row)) {
+                               $arrayKeys = range(0,count($row));
+                               array_fill_keys($arrayKeys, $row);
+                               $rows[] = $row;
                        }
-                       $where = (implode(' AND ', $whereParts));
-               } if (is_string($constraint)) {
-                       $where = $constraint;
                }
-               return $where;
+               $this->persistenceBackend->sql_free_result($res);
+               return $rows;
        }
        
-       /**
-        * Replace query placeholders in a query part by the given
-        * parameters.
-        *
-        * @param string $queryPart The query part with placeholders
-        * @param array $parameters The parameters
-        *
-        * @return string The query part with replaced placeholders
-        */
-       protected function replacePlaceholders(Tx_Extbase_Persistence_Mapper_DataMap $dataMap, $queryPart, $parameters) {
-               $sql = $queryPart;
-               foreach ($parameters as $parameter) {
-                       $markPosition = strpos($sql, '?');
-                       if ($markPosition !== FALSE) {
-                               $sql = substr($sql, 0, $markPosition) . $dataMap->convertPropertyValueToFieldValue($parameter) . substr($sql, $markPosition + 1);
+       protected function getFieldMapFromResult($res) {
+               $fieldMap = array();
+               if ($res !== FALSE) {
+                       $fieldPosition = 0;
+                       // TODO mysql_fetch_field should be available in t3lib_db (patch core)
+                       while ($field = mysql_fetch_field($res)) {
+                               $fieldMap[$field->table][$field->name] = $fieldPosition;
+                               $fieldPosition++;
                        }
                }
-               return $sql;
+               return $fieldMap;
        }
        
-       
-       /**
-        * Get a where part for an example condition (associative array). This also works
-        * for nested conditions.
-        *
-        * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap The data map
-        * @param array $propertyName The property name
-        * @param array $example The example condition
-        *
-        * @return string The where part
-        */
-       protected function generateWhereClauseByExample(Tx_Extbase_Persistence_Mapper_DataMap $dataMap, $propertyName, $example) {
-               $columnMap = $dataMap->getColumnMap($propertyName);
-               $sql = '';
-               if (empty($columnMap)) {
-                       throw new Tx_Extbase_Persistence_Exception_InvalidPropertyType("No columnMap for $propertyName", 1240305176);
-               }
-               if (!is_array($example)) {
-                       $column = $dataMap->getTableName() . '.' . $columnMap->getColumnName();
-                       $sql = $column . ' = ' . $dataMap->convertPropertyValueToFieldValue($example);
-               } else {
-                       $childDataMap = $this->dataMapper->getDataMap($columnMap->getChildClassName());
-                       $sql = $this->generateWhereClause($childDataMap, $example);
-               }
-               return $sql;
-       }
-
-       /**
-        * Sets the WHERE Statement
-        *
-        * @param string $where The WHERE statement
-        * @return void
-        */
-       public function setWhereClause($where) {
-               $this->where = $where;
-       }
-
-       /**
-        * Sets the GROUP BY Statement
-        *
-        * @param string $groupBy The GROUP BY statement
-        * @return void
-        */
-       public function setGroupByClause($groupBy) {
-               $this->groupBy = $groupBy;
-       }
-
-       /**
-        * Sets the ORDER BY Statement
-        *
-        * @param string $orderBy The ORDER BY statement
-        * @return void
-        */
-       public function setOrderByClause($orderBy) {
-               $this->orderBy = $orderBy;
-       }
-
-       /**
-        * Sets the maximum size of the result set to limit.
-        *
-        * @param integer $limit
-        * @return void
-        */
-       public function setLimit($limit) {
-               if ($limit < 1 || !is_int($limit)) {
-                       throw new InvalidArgumentException('setLimit() accepts only integers greater than 0.', 1217244746);
-               }
-               $this->limit = $limit;
-       }
-
-       /**
-        * Sets the start offset of the result set to offset.
-        *
-        * @param integer $offset
-        * @return void
-        */
-       public function setOffset($offset) {
-               if ($offset < 0 || !is_int($offset)) {
-                       throw new InvalidArgumentException('setOffset() accepts only integers greater than or equal to 0.', 1217245454);
-               }
-               $this->offset = $offset;
-       }
-
 }
 ?>
\ No newline at end of file
index 7298605..5d7e89b 100644 (file)
@@ -40,6 +40,8 @@ class Tx_Extbase_Persistence_QueryFactory implements Tx_Extbase_Persistence_Quer
        public function create($className) {
                // TODO Make the Query class configurable
                $query = t3lib_div::makeInstance('Tx_Extbase_Persistence_Query', $className);
+               // TODO Make the responsible Persistence Backend configurable
+               $query->injectPersistenceBackend($GLOBALS['TYPO3_DB']);
                // TODO Make the responsible Data Mapper configurable
                $query->injectDataMapper(t3lib_div::makeInstance('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', $GLOBALS['TYPO3_DB']));
                return $query;
index 70a8deb..137ccb5 100644 (file)
@@ -41,10 +41,10 @@ interface Tx_Extbase_Persistence_QueryInterface {
        /**
         * The constraint used to limit the result set
         *
-        * @param mixed $constraint Some constraint, depending on the backend
+        * @param Tx_Extbase_Persistence_ConstraintInterface $constraint Some constraint, depending on the backend
         * @return Tx_Extbase_Persistence_QueryInterface
         */
-       public function matching($constraint);
+       public function matching(Tx_Extbase_Persistence_ConstraintInterface $constraint);
 
 }
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/RawSqlConstraint.php b/typo3/sysext/extbase/Classes/Persistence/RawSqlConstraint.php
new file mode 100644 (file)
index 0000000..22f431b
--- /dev/null
@@ -0,0 +1,73 @@
+<?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!
+***************************************************************/
+
+/**
+ * The interface for constraints
+ *
+ * @package TYPO3
+ * @subpackage Extbase
+ * @version $Id: $
+ * @scope prototype
+ */
+class Tx_Extbase_Persistence_RawSqlConstraint implements Tx_Extbase_Persistence_ConstraintInterface {
+       
+       /**
+        * The SQL statement
+        *
+        * @var string
+        **/
+       protected $statement;
+       
+       /**
+        * Constructs this constraint
+        *
+        * @param string $statement 
+        */
+       public function __construct($statement) {
+               $this->setStatement($statement);
+       }
+       
+       /**
+        * Sets the statement
+        *
+        * @param string $statement 
+        * @return void
+        */
+       public function setStatement($statement) {
+               if (!is_string($statement)) throw new InvalidArgumentException('The statement must be of type string, ' . gettype($statement) . ' given.', 1187951688);
+               $this->statement = $statement;
+       }
+       
+       /**
+        * Returns the statement
+        *
+        * @return string The SQL statement
+        */
+       public function getStatement() {
+               return $this->statement;
+       }
+       
+}
+
+?>
\ No newline at end of file
index ed922be..eab7959 100644 (file)
@@ -35,6 +35,11 @@ require_once(PATH_tslib . 'class.tslib_content.php');
 class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_RepositoryInterface, t3lib_Singleton {
 
        /**
+        * @var Tx_Extbase_Persistence_QueryFactoryInterface
+        */
+       protected $queryFactory;
+
+       /**
         * Class Name of the aggregate root
         *
         * @var string
@@ -68,6 +73,7 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
                }
                $this->dataMapper = t3lib_div::makeInstance('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', $GLOBALS['TYPO3_DB']); // singleton
                $this->persistenceSession = t3lib_div::makeInstance('Tx_Extbase_Persistence_Session'); // singleton
+               $this->queryFactory = t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory');
        }
 
        /**
@@ -116,6 +122,35 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
                        throw new Tx_Extbase_Persistence_Exception_UnknownObject('The "existing object" is unknown to the persistence backend.', 1238068475);
                }
        }
+       
+       // TODO Implement Query Object
+       // /**
+       //  * Returns all objects of this repository
+       //  *
+       //  * @return array An array of objects, empty if no objects found
+       //  */
+       // public function findAll() {
+       //      return $this->createQuery()->execute();
+       // }
+       
+       /**
+        * Returns all objects of this repository
+        *
+        * @return array An array of objects, empty if no objects found
+        */
+       public function findAll() {
+               return $this->findWhere();
+       }
+       
+       /**
+        * Returns a query for objects of this repository
+        *
+        * @return Tx_Extbase_Persistence_QueryInterface
+        */
+       public function createQuery() {
+               $type = str_replace('Repository', '', get_class($this));
+               return $this->queryFactory->create($type);
+       }
                
        /**
         * Dispatches magic methods (findBy[Property]())
@@ -188,13 +223,5 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
                return $objects;
        }
 
-       /**
-        * Returns all objects of this repository
-        *
-        * @return array An array of objects, empty if no objects found
-        */
-       public function findAll() {
-               return $this->findWhere();
-       }
 }
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Persistence/SqlConstraint.php b/typo3/sysext/extbase/Classes/Persistence/SqlConstraint.php
new file mode 100644 (file)
index 0000000..5cd5a53
--- /dev/null
@@ -0,0 +1,241 @@
+<?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!
+***************************************************************/
+
+/**
+ * The interface for constraints
+ *
+ * @package TYPO3
+ * @subpackage Extbase
+ * @version $Id: $
+ * @scope prototype
+ */
+class Tx_Extbase_Persistence_SqlConstraint implements Tx_Extbase_Persistence_ConstraintInterface {
+       
+       /**
+        * @var string
+        */
+       protected $where;
+
+       /**
+        * @var string
+        */
+       protected $groupBy;
+
+       /**
+        * @var string
+        */
+       protected $orderBy;
+
+       /**
+        * @var integer
+        */
+       protected $limit;
+
+       /**
+        * @var integer
+        */
+       protected $offset;
+       
+       /**
+        * @var boolean
+        */
+       protected $useEnableFields = TRUE;
+
+       /**
+        * The SQL statement
+        *
+        * @var string
+        **/
+       protected $statement;
+               
+       /**
+        * Sets the statement
+        *
+        * @param string $statement 
+        * @return void
+        */
+       public function setStatement($statement) {
+               if (!is_string($statement)) throw new InvalidArgumentException('The statement must be of type string, ' . gettype($statement) . ' given.', 1187951688);
+               $this->statement = $statement;
+       }
+       
+       /**
+        * Returns the statement
+        *
+        * @return string The SQL statement
+        */
+       public function getStatement() {
+               
+
+       }
+       
+       /**
+        * Sets the WHERE Statement
+        *
+        * @param string $where The WHERE statement
+        * @return void
+        */
+       public function setWhereClause($where) {
+               if (!is_string($where)) throw new InvalidArgumentException('The where clause must be of type string, ' . gettype($where) . ' given.', 1187951688);
+               $this->where = $where;
+       }
+
+       /**
+        * Sets the GROUP BY Statement
+        *
+        * @param string $groupBy The GROUP BY statement
+        * @return void
+        */
+       public function setGroupByClause($groupBy) {
+               if (!is_string($groupBy)) throw new InvalidArgumentException('The group by clause must be of type string, ' . gettype($groupBy) . ' given.', 1187951688);
+               $this->groupBy = $groupBy;
+       }
+
+       /**
+        * Sets the ORDER BY Statement
+        *
+        * @param string $orderBy The ORDER BY statement
+        * @return void
+        */
+       public function setOrderByClause($orderBy) {
+               if (!is_string($orderBy)) throw new InvalidArgumentException('The order by clause must be of type string, ' . gettype($orderBy) . ' given.', 1187951688);
+               $this->orderBy = $orderBy;
+       }
+
+       /**
+        * Sets the maximum size of the result set to limit.
+        *
+        * @param integer $limit
+        * @return void
+        */
+       public function setLimit($limit) {
+               if ($limit < 1 || !is_int($limit)) {
+                       throw new InvalidArgumentException('setLimit() accepts only integers greater than 0.', 1217244746);
+               }
+               $this->limit = $limit;
+       }
+
+       /**
+        * Sets the start offset of the result set to offset.
+        *
+        * @param integer $offset
+        * @return void
+        */
+       public function setOffset($offset) {
+               if ($offset < 0 || !is_int($offset)) {
+                       throw new InvalidArgumentException('setOffset() accepts only integers greater than or equal to 0.', 1217245454);
+               }
+               $this->offset = $offset;
+       }
+       
+       /**
+        * The following condition array would find entities with description like the given keyword and
+        * name equal to "foo".
+        *
+        * <pre>
+        * array(
+        *              array('blog_description LIKE ?', $keyword),
+        *              '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 Tx_Extbase_Persistence_Mapper_DataMap $dataMap The data map
+        * @param Tx_Extbase_Persistence_ConstraintInterface $constraint The constraint
+        * @return string The query where part for the class and given conditions
+        */
+       public function generateWhereClause(Tx_Extbase_Persistence_Mapper_DataMap $dataMap, Tx_Extbase_Persistence_ConstraintInterface $constraint) {
+               $where = '';
+               if (is_array($constraint)) {
+                       $whereParts = array();
+                       foreach ($constraint as $key => $condition) {
+                               if (is_array($condition) && isset($condition[0])) {
+                                       $sql = $this->replacePlaceholders($dataMap, $condition[0], array_slice($condition, 1));
+                                       $whereParts[] = '(' . $sql . ')';
+                               } elseif (is_string($key)) {
+                                       $sql = $this->generateWhereClauseByExample($dataMap, $key, $condition);
+                                       if (strlen($sql) > 0) {
+                                               $whereParts[] = '(' . $sql . ')';
+                                       }
+                               }
+                       }
+                       $where = (implode(' AND ', $whereParts));
+               } if (is_string($constraint)) {
+                       $where = $constraint;
+               }
+               return $where;
+       }
+       
+       /**
+        * Replace query placeholders in a query part by the given
+        * parameters.
+        *
+        * @param string $queryPart The query part with placeholders
+        * @param array $parameters The parameters
+        *
+        * @return string The query part with replaced placeholders
+        */
+       protected function replacePlaceholders(Tx_Extbase_Persistence_Mapper_DataMap $dataMap, $queryPart, $parameters) {
+               $sql = $queryPart;
+               foreach ($parameters as $parameter) {
+                       $markPosition = strpos($sql, '?');
+                       if ($markPosition !== FALSE) {
+                               $sql = substr($sql, 0, $markPosition) . $dataMap->convertPropertyValueToFieldValue($parameter) . substr($sql, $markPosition + 1);
+                       }
+               }
+               return $sql;
+       }
+       
+       
+       /**
+        * Get a where part for an example condition (associative array). This also works
+        * for nested conditions.
+        *
+        * @param Tx_Extbase_Persistence_Mapper_DataMap $dataMap The data map
+        * @param array $propertyName The property name
+        * @param array $example The example condition
+        *
+        * @return string The where part
+        */
+       protected function generateSqlByExample(Tx_Extbase_Persistence_Mapper_DataMap $dataMap, $propertyName, $example) {
+               $columnMap = $dataMap->getColumnMap($propertyName);
+               $sql = '';
+               if (empty($columnMap)) {
+                       throw new Tx_Extbase_Persistence_Exception_InvalidPropertyType("No columnMap for $propertyName", 1240305176);
+               }
+               if (!is_array($example)) {
+                       $column = $dataMap->getTableName() . '.' . $columnMap->getColumnName();
+                       $sql = $column . ' = ' . $dataMap->convertPropertyValueToFieldValue($example);
+               } else {
+                       $childDataMap = $this->dataMapper->getDataMap($columnMap->getChildClassName());
+                       $sql = $this->generateWhereClause($childDataMap, $example);
+               }
+               return $sql;
+       }
+       
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Documentation/t3lib_extMgm_addExtbasePlugin.diff b/typo3/sysext/extbase/Documentation/t3lib_extMgm_addExtbasePlugin.diff
deleted file mode 100644 (file)
index 7f198c6..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
---- typo3_src-trunk.orig/t3lib/class.t3lib_extmgm.php  2009-04-16 17:41:01.000000000 +0200
-+++ typo3_src-trunk/t3lib/class.t3lib_extmgm.php       2009-04-16 17:56:59.000000000 +0200
-@@ -994,7 +994,7 @@
-                       // General plugin:
-               $pluginContent = trim('
--plugin.'.$cN.$prefix.' = USER' . ($cached ? '' : '_INT') . '
-+plugin.'.$cN.$prefix.' = ' . ($cached ? 'USER' : 'USER_INT') . '
- plugin.'.$cN.$prefix.' {
-   includeLibs = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.'
-   userFunc = '.$cN.$prefix.'->main
-@@ -1042,6 +1042,119 @@
-       }
-       /**
-+       * Add an Extbase PlugIn to TypoScript
-+       *
-+       * When adding a frontend plugin you will have to add both an entry to the TCA definition 
-+       * of tt_content table AND to the TypoScript template which must initiate the rendering.
-+       * Since the static template with uid 43 is the "content.default" and practically always 
-+       * used for rendering the content elements it's very useful to have this function automatically 
-+       * adding the necessary TypoScript for calling your plugin. It will also work for the 
-+       * extension "css_styled_content"
-+       * FOR USE IN ext_locallang.php FILES
-+       * Usage: 2
-+       *
-+       * @param       string          $pluginKey must be a unique id for your plugin in lower_underscore (the string length of the extension key added to the length of the plugin key should be less than 32!)
-+       * @param       string          $extensionKEy is the extension key in lower_underscore (available in $_EXTKEY)
-+       * @param       string          $controllerActions is an array of allowed combinations of controller and action stored in an array (controller name as key and a comma separated list of action names as value)
-+       * @param       string          $nonCachableControllerActions is an optional array of controller name and  action names which should not be cached (array as defined in $controllerActions)
-+       * @param       string          $defaultControllerAction is an optional array controller name (as array key) and action name (as array value) that should be called as default
-+       * @return      void
-+       */
-+      // TODO tt_content field 'list_type' should be enabled to hold at least 128 characters
-+      public static function addExtbasePlugin($pluginKey, $extensionKey, array $controllerActions = array(), array $nonCachableControllerActions = array(), $defaultControllerAction = NULL) {
-+              if (empty($pluginKey)) {
-+                      throw new InvalidArgumentException('The plugin key must not be empty', 1239891987);
-+              }
-+              if (empty($extensionKey) || preg_match('/[^_a-z0-9]/', $extensionKey) === 1) {
-+                      throw new InvalidArgumentException('The extension key was invalid (must not be empty and must match [_a-z0-9])', 1239891989);
-+              }
-+              $extensionName = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($extensionKey))));
-+
-+              $controllerCounter = 1;
-+              $hasMultipleActionsCounter = 0;
-+              $controllers = '';
-+              foreach ($controllerActions as $controller => $actionsList) {
-+                      $controllers .= '
-+              ' . $controllerCounter . '.controller = ' . $controller . '
-+              ' . $controllerCounter . '.actions = ' . $actionsList;
-+                      $controllerCounter++;
-+                      if (strpos($actionsList, ',') !== FALSE) {
-+                              $hasMultipleActionsCounter++;
-+                      }
-+              }
-+              if ($hasMultipleActionsCounter > 0) {
-+                              $switchableControllerActions = '
-+      switchableControllerActions {' . $controllers . '
-+      }';
-+              } else {
-+                      $switchableControllerActions = '';
-+              }
-+              
-+              reset($controllerActions);
-+              if ($defaultControllerAction !== NULL) {
-+                      $defaultController = key($defaultControllerAction);
-+                      $controller = '
-+      controller = ' . $defaultController;
-+                      $defaultAction = current($defaultControllerAction);
-+                      $action = '
-+      action = ' . $defaultAction;
-+              } elseif (!empty($controllerActions)) {
-+                      $defaultController = key($controllerActions);
-+                      $controller = '
-+      controller = ' . $defaultController;
-+                      $defaultAction = array_shift(t3lib_div::trimExplode(',', current($controllerActions)));
-+                      $action = '
-+      action = ' . $defaultAction;
-+              } else {
-+                      $defaultController = NULL;
-+                      $controller = '';
-+                      $defaultAction = NULL;
-+                      $action = '';
-+              }
-+
-+              if (!empty($nonCachableControllerActions[$defaultController])) {
-+                      $nonCachableActions = t3lib_div::trimExplode(',', $nonCachableControllerActions[$defaultController]);
-+              } else {
-+                      $nonCachableActions = array();
-+              }
-+              $cachableActions = array_diff(t3lib_div::trimExplode(',', $controllerActions[$defaultController]), $nonCachableActions);
-+              $contentObjectType = in_array($defaultAction, $nonCachableActions) ? 'USER_INT' : 'USER';
-+
-+              $conditions = '';
-+              foreach ($controllerActions as $controllerName => $actionsList) {
-+                      if (!empty($nonCachableControllerActions[$controllerName])) {
-+                              $nonCachableActions = t3lib_div::trimExplode(',', $nonCachableControllerActions[$controllerName]);
-+                              $cachableActions = array_diff(t3lib_div::trimExplode(',', $controllerActions[$controllerName]), $nonCachableActions);
-+                              if ((($contentObjectType === 'USER') && (count($nonCachableActions) !== 0)) || (($contentObjectType === 'USER_INT') && (count($cachableActions) !== 0))) {
-+                                      $conditions .= '
-+[globalString: GP = tx_' . strtolower($extensionName) . '_' . strtolower($pluginKey) . '|controller = ' . $controllerName . '] && [globalString: GP = tx_' . strtolower($extensionName) . '_' . strtolower($pluginKey) . '|action = /' . implode('|', $contentObjectType === 'USER' ? $nonCachableActions : $cachableActions) . '/]
-+tt_content.list.20.' . strtolower($extensionKey) . '_' . strtolower($pluginKey) . ' = ' . ($contentObjectType === 'USER' ? 'USER_INT' : 'USER') . '
-+[global]
-+';
-+                              }
-+                      }
-+              }
-+              
-+              $pluginContent = trim('
-+includeLibs.tx_extbase_dispatcher = EXT:extbase/class.tx_extbase_dispatcher.php
-+
-+tt_content.list.20.' . strtolower($extensionKey) . '_' . strtolower($pluginKey) . ' = ' . $contentObjectType . '
-+tt_content.list.20.' . strtolower($extensionKey) . '_' . strtolower($pluginKey) . ' {
-+      userFunc = tx_extbase_dispatcher->dispatch
-+      pluginKey = ' . $pluginKey . '
-+      extensionName = ' . $extensionName .
-+      $controller .
-+      $action . 
-+      $switchableControllerActions . '
-+}
-+' . $conditions);
-+
-+              t3lib_extMgm::addTypoScript($extensionKey, 'setup', '
-+# Setting ' . $extensionKey . ' plugin TypoScript
-+' . $pluginContent, 43);
-+      }
-+
-+      /**
-        * Call this method to add an entry in the static template list found in sys_templates
-        * "static template files" are the modern equalent (provided from extensions) to the traditional records in "static_templates"
-        * FOR USE IN ext_localconf.php FILES
diff --git a/typo3/sysext/extbase/Documentation/t3lib_extMgm_testcase.php b/typo3/sysext/extbase/Documentation/t3lib_extMgm_testcase.php
deleted file mode 100644 (file)
index ec906ca..0000000
+++ /dev/null
@@ -1,294 +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!
-***************************************************************/
-
-
-/**
- * Testcase for class t3lib_extmgm
- *
- * @package TYPO3
- * @subpackage t3lib
- */
-class t3lib_extMgm_testcase extends tx_phpunit_testcase {
-       
-       public function setUp() {
-               global $TYPO3_CONF_VARS;
-               $this->TYPO3_CONF_VARS_backup = $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-       }
-       
-       public function tearDown() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS = $this->TYPO3_CONF_VARS_before;
-       }
-       
-       /**
-        * @test
-        */
-       public function addingTsWorksForMinimalisticSetup() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginkey',
-                       'my_extension'
-               );
-               $staticTypoScript = $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'];             
-
-               $this->assertContains('includeLibs.tx_extbase_dispatcher = EXT:extbase/class.tx_extbase_dispatcher.php', $staticTypoScript, 'Did not include "tx_extbase_dispatcher".');
-               $this->assertContains('tt_content.list.20.my_extension_pluginkey = USER', $staticTypoScript);
-               $this->assertContains('
-       pluginKey = pluginkey
-       extensionName = MyExtension', $staticTypoScript);
-       $this->assertNotContains('controller =', $staticTypoScript);
-       $this->assertNotContains('action =', $staticTypoScript);
-               $this->assertNotContains('USER_INT', $staticTypoScript);
-       }
-       
-       /**
-        * @test
-        */
-       public function addingTsWorksForASingleControllerAction() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginkey',
-                       'my_extension',
-                       array(
-                               'FirstController' => 'index'
-                               )
-               );
-               $staticTypoScript = $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'];             
-
-               $this->assertContains('includeLibs.tx_extbase_dispatcher = EXT:extbase/class.tx_extbase_dispatcher.php', $staticTypoScript, 'Did not include "tx_extbase_dispatcher".');
-               $this->assertContains('tt_content.list.20.my_extension_pluginkey = USER', $staticTypoScript);
-               $this->assertContains('
-       pluginKey = pluginkey
-       extensionName = MyExtension
-       controller = FirstController
-       action = index', $staticTypoScript);
-               $this->assertNotContains('USER_INT', $staticTypoScript);
-       }
-       
-       /**
-        * @test
-        */
-       public function addingPluginWithEmptyPluginKeyResultsInAnError() {
-               $this->setExpectedException('InvalidArgumentException');
-               t3lib_extMgm::addExtbasePlugin(
-                       '',
-                       'my_extension',
-                       array(
-                               'FirstController' => 'index'
-                               )
-               );
-       }
-       
-       /**
-        * @test
-        */
-       public function addingPluginWithEmptyExtensionKeyResultsInAnError() {
-               $this->setExpectedException('InvalidArgumentException');
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginKey',
-                       '',
-                       array(
-                               'FirstController' => 'index'
-                               )
-               );
-       }
-
-       /**
-        * @test
-        */
-       public function addingPluginWithInvalidExtensionKeyResultsInAnError() {
-               $this->setExpectedException('InvalidArgumentException');
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginKey',
-                       'MyExtension',
-                       array(
-                               'FirstController' => 'index'
-                               )
-               );
-       }
-
-       /**
-        * @test
-        */
-       public function theDefaultControllerActionCanBeSetManually() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginkey',
-                       'my_extension',
-                       array(
-                               'FirstController' => 'index,show,new,create,delete,edit,update',
-                               'SecondController' => 'index,show,delete',
-                               'ThirdController' => 'create'
-                               ),
-                       array(),
-                       array('SecondController' => 'show')     
-                       );
-               $staticTypoScript = $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'];             
-
-               $this->assertContains('
-       pluginKey = pluginkey
-       extensionName = MyExtension
-       controller = SecondController
-       action = show', $staticTypoScript);
-       }
-
-       /**
-        * @test
-        */
-       public function addingPluginRespectsDefaultActionAsANonCachableAction() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginkey',
-                       'my_extension',
-                       array(
-                               'FirstController' => 'index,show,new,create,delete,edit,update'
-                               ),
-                       array(
-                               'FirstController' => 'index,show'
-                               )
-                       );
-               $staticTypoScript = $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'];             
-
-               $this->assertContains('
-tt_content.list.20.my_extension_pluginkey = USER_INT
-tt_content.list.20.my_extension_pluginkey {', $staticTypoScript);
-               $this->assertContains('
-[globalString: GP = tx_myextension_pluginkey|controller = FirstController] && [globalString: GP = tx_myextension_pluginkey|action = /new|create|delete|edit|update/]
-tt_content.list.20.my_extension_pluginkey = USER', $staticTypoScript);
-       }
-
-       /**
-        * @test
-        */
-       public function addingPluginRespectsNonDefaultActionAsANonCachableAction() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginkey',
-                       'my_extension',
-                       array(
-                               'FirstController' => 'index,show,new,create,delete,edit,update'
-                               ),
-                       array(
-                               'FirstController' => 'show,new'
-                               )
-                       );
-               $staticTypoScript = $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'];             
-
-               $this->assertContains('
-tt_content.list.20.my_extension_pluginkey = USER
-tt_content.list.20.my_extension_pluginkey {', $staticTypoScript);
-               $this->assertContains('
-[globalString: GP = tx_myextension_pluginkey|controller = FirstController] && [globalString: GP = tx_myextension_pluginkey|action = /show|new/]
-tt_content.list.20.my_extension_pluginkey = USER_INT', $staticTypoScript);
-       }
-
-       /**
-        * @test
-        */
-       public function addingPluginWorksForMultipleControllerActionsWithCachableActionAsDefault() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginkey',
-                       'my_extension',
-                       array(
-                               'FirstController' => 'index,show,new,create,delete,edit,update',
-                               'SecondController' => 'index,show,delete',
-                               'ThirdController' => 'create'
-                               ),
-                       array(
-                               'FirstController' => 'new,create,edit,update',
-                               'SecondController' => 'delete',
-                               'ThirdController' => 'create'
-                               ),
-                       array('SecondController' => 'show')     
-                       );
-               $staticTypoScript = $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'];             
-       
-               $this->assertContains('
-tt_content.list.20.my_extension_pluginkey = USER
-tt_content.list.20.my_extension_pluginkey {', $staticTypoScript);
-
-               $this->assertContains('
-[globalString: GP = tx_myextension_pluginkey|controller = FirstController] && [globalString: GP = tx_myextension_pluginkey|action = /new|create|edit|update/]
-tt_content.list.20.my_extension_pluginkey = USER_INT', $staticTypoScript);
-
-               $this->assertContains('
-[globalString: GP = tx_myextension_pluginkey|controller = SecondController] && [globalString: GP = tx_myextension_pluginkey|action = /delete/]
-tt_content.list.20.my_extension_pluginkey = USER_INT', $staticTypoScript);
-
-               $this->assertContains('
-[globalString: GP = tx_myextension_pluginkey|controller = ThirdController] && [globalString: GP = tx_myextension_pluginkey|action = /create/]
-tt_content.list.20.my_extension_pluginkey = USER_INT', $staticTypoScript);
-       }
-
-
-       /**
-        * @test
-        */
-       public function addingPluginWorksForMultipleControllerActionsWithNonCachableActionAsDefault() {
-               global $TYPO3_CONF_VARS;
-               $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'] = '';
-               t3lib_extMgm::addExtbasePlugin(
-                       'pluginkey',
-                       'my_extension',
-                       array(
-                               'FirstController' => 'index,show,new,create,delete,edit,update',
-                               'SecondController' => 'index,show,delete',
-                               'ThirdController' => 'create'
-                               ),
-                       array(
-                               'FirstController' => 'new,create,edit,update',
-                               'SecondController' => 'delete',
-                               'ThirdController' => 'create'
-                               ),
-                       array('SecondController' => 'delete')   
-                       );
-               $staticTypoScript = $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup.']['cssstyledcontent/static/current/'];             
-
-               $this->assertContains('
-tt_content.list.20.my_extension_pluginkey = USER_INT
-tt_content.list.20.my_extension_pluginkey {', $staticTypoScript);
-
-               $this->assertContains('
-[globalString: GP = tx_myextension_pluginkey|controller = FirstController] && [globalString: GP = tx_myextension_pluginkey|action = /index|show|delete/]
-tt_content.list.20.my_extension_pluginkey = USER', $staticTypoScript);
-
-               $this->assertContains('
-[globalString: GP = tx_myextension_pluginkey|controller = SecondController] && [globalString: GP = tx_myextension_pluginkey|action = /index|show/]
-tt_content.list.20.my_extension_pluginkey = USER', $staticTypoScript);
-
-               $this->assertNotContains('[globalString: GP = tx_myextension_pluginkey|controller = ThirdController]', $staticTypoScript);
-       }
-
-
-}
-
-?>
\ No newline at end of file
index 6a469ea..e281047 100644 (file)
@@ -28,13 +28,7 @@ require_once(t3lib_extMgm::extPath('extbase', 'class.tx_extbase_dispatcher.php')
  * Base testcase for the Extbase extension. Currently it only registers the autoloader.
  */
 abstract class Tx_Extbase_Base_testcase extends tx_phpunit_testcase {
-       
-       public function __construct() {
-               parent::__construct();
-               $dispatcher = t3lib_div::makeInstance('Tx_Extbase_Dispatcher');
-               spl_autoload_register(array($dispatcher, 'autoLoadClasses'));
-       }
-       
+
        /**
         * Creates a proxy class of the specified class which allows            
         * for calling even protected methods and access of protected properties.
index 940b52b..4afca83 100644 (file)
@@ -31,7 +31,7 @@ class Tx_Extbase_MVC_Web_RequestBuilder_testcase extends Tx_Extbase_Base_testcas
        public function setUp() {
                $this->configuration = array(
                        'userFunc' => 'tx_extbase_dispatcher->dispatch',
-                       'pluginKey' => 'pluginkey',
+                       'pluginName' => 'pi1',
                        'extensionName' => 'MyExtension',
                        'controller' => 'TheFirstController',
                        'action' => 'show',
@@ -57,7 +57,7 @@ class Tx_Extbase_MVC_Web_RequestBuilder_testcase extends Tx_Extbase_Base_testcas
                $this->builder->initialize($this->configuration);
                $request = $this->builder->build();
                $this->assertEquals('Tx_Extbase_MVC_Web_Request', get_class($request));
-               $this->assertEquals('pluginkey', $request->getPluginKey());
+               $this->assertEquals('pi1', $request->getPluginKey());
                $this->assertEquals('MyExtension', $request->getControllerExtensionName());
                $this->assertEquals('TheFirstController', $request->getControllerName());
                $this->assertEquals('show', $request->getControllerActionName());
@@ -78,7 +78,7 @@ class Tx_Extbase_MVC_Web_RequestBuilder_testcase extends Tx_Extbase_Base_testcas
                unset($configuration['switchableControllerActions.']);
                $this->builder->initialize($configuration);
                $request = $this->builder->build();
-               $this->assertEquals('pluginkey', $request->getPluginKey());
+               $this->assertEquals('pi1', $request->getPluginKey());
                $this->assertEquals('MyExtension', $request->getControllerExtensionName());
                $this->assertEquals('Default', $request->getControllerName());
                $this->assertEquals('index', $request->getControllerActionName());
@@ -90,7 +90,7 @@ class Tx_Extbase_MVC_Web_RequestBuilder_testcase extends Tx_Extbase_Base_testcas
                unset($configuration['action']);
                $this->builder->initialize($configuration);
                $request = $this->builder->build();
-               $this->assertEquals('pluginkey', $request->getPluginKey());
+               $this->assertEquals('pi1', $request->getPluginKey());
                $this->assertEquals('MyExtension', $request->getControllerExtensionName());
                $this->assertEquals('TheFirstController', $request->getControllerName());
                $this->assertEquals('show', $request->getControllerActionName());
index b09f924..8dae9af 100644 (file)
@@ -33,17 +33,24 @@ class Tx_Extbase_Persistence_Query_testcase extends Tx_Extbase_Base_testcase {
                        ->will($this->returnValue(NULL));               
                $this->dataMapper = $this->getMock('Tx_Extbase_Persistence_Mapper_ObjectRelationalMapper', array(), array($dataBase));
                $this->query = new Tx_Extbase_Persistence_Query('Tx_MyExtension_Domain_Model_Class');
+               $this->query->injectPersistenceBackend($dataBase);
                $this->query->injectDataMapper($this->dataMapper);
        }
 
-       public function test_generateWhereClauseWithRawStatement() {
+       public function test_queryObjectImplementsQueryInterface() {
                $query = clone($this->query);
-               $dataMap = $this->getMock('Tx_Extbase_Persistence_Mapper_DataMap', array(), array('Tx_MyExtension_Domain_Model_Class'));
-               $whereClause = $query->generateWhereClause($dataMap, "foo='bar' AND baz=1");
                
-               $this->assertEquals("foo='bar' AND baz=1", $whereClause);
+               $this->assertTrue($query instanceof Tx_Extbase_Persistence_QueryInterface);
        }
        
+       // public function test_generateWhereClauseWithRawStatement() {
+       //      $query = $this->getMock($this->buildAccessibleProxy(('Tx_Extbase_Persistence_Query'), array(), array('Tx_MyExtension_Domain_Model_Class')));
+       //      $constraint = $this->getMock('Tx_Extbase_Persistence_RawSqlConstraint', array('dummy'), array("SELECT * FROM tx_myextension_domain_model_class WHERE foo='bar'"));
+       //      $query->matching($constraint);
+       //      
+       //      $this->assertEquals($constraint, $query->_get('constraint'));
+       // }
+       // 
        // public function test_generateWhereClauseWithPlaceholders() {
        //      $query = clone($this->query);
        //