[+BUGFIX] Extbase (Tests): Fixed several unit tests. Speeded up unit tests by replaci...
authorJochen Rau <j.rau@web.de>
Mon, 12 Oct 2009 17:51:54 +0000 (17:51 +0000)
committerJochen Rau <j.rau@web.de>
Mon, 12 Oct 2009 17:51:54 +0000 (17:51 +0000)
[+BUGFIX] Extbase (MVC): Added missing Tx_Extbase_MVC_Exception_InvalidOrNoRequestHash.

typo3/sysext/extbase/Classes/MVC/Exception/InvalidOrNoRequestHash.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Configuration/BackendConfigurationManager_testcase.php
typo3/sysext/extbase/Tests/Configuration/Source/FlexFormSource_testcase.php
typo3/sysext/extbase/Tests/Configuration/Source/TypoScriptSource_testcase.php
typo3/sysext/extbase/Tests/MVC/Controller/ActionController_testcase.php
typo3/sysext/extbase/Tests/Validation/ValidatorResolver_testcase.php

diff --git a/typo3/sysext/extbase/Classes/MVC/Exception/InvalidOrNoRequestHash.php b/typo3/sysext/extbase/Classes/MVC/Exception/InvalidOrNoRequestHash.php
new file mode 100644 (file)
index 0000000..7881a2a
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+*  All rights reserved
+*
+*  This class is a backport of the corresponding class of FLOW3. 
+*  All credits go to the v5 team.
+*
+*  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!
+***************************************************************/
+
+/**
+ * An "Invalid Request Method" exception
+ *
+ * @package Extbase
+ * @subpackage MVC\Exception
+ * @version $Id$
+ */
+class Tx_Extbase_MVC_Exception_InvalidOrNoRequestHash extends Tx_Extbase_MVC_Exception {
+
+}
+?>
\ No newline at end of file
index 58dae63..303cbf4 100644 (file)
@@ -72,7 +72,7 @@ class Tx_Extbase_Configuration_BackendConfigurationManager_testcase extends Tx_E
         * @test
         */
        public function loadTypoScriptSetupCantBeTested() {
-               $this->markTestSkipped('This method can\'t be tested with the current TYPO3 version, because we can\'t mock objects returned from t3lib_div::makeInstance().');
+               $this->markTestIncomplete('This method can\'t be tested with the current TYPO3 version, because we can\'t mock objects returned from t3lib_div::makeInstance().');
        }
 
        /**
index 4ddac77..ba78d6a 100644 (file)
@@ -31,7 +31,7 @@ class Tx_Extbase_Configuration_Source_FlexFormSource_testcase extends Tx_Extbase
         * @test
         */
        public function xy() {
-               $this->markTestSkipped('No test has been written for class Tx_Extbase_Configuration_Source_FlexFormSource');
+               $this->markTestIncomplete('No test has been written for class Tx_Extbase_Configuration_Source_FlexFormSource');
        }
 }
 ?>
\ No newline at end of file
index ff61879..62601f1 100644 (file)
@@ -31,7 +31,7 @@ class Tx_Extbase_Configuration_Source_TypoScriptSource_testcase extends Tx_Extba
         * @test
         */
        public function xy() {
-               $this->markTestSkipped('No test has been written for class Tx_Extbase_Configuration_Source_TypoScriptSource');
+               $this->markTestIncomplete('No test has been written for class Tx_Extbase_Configuration_Source_TypoScriptSource');
        }
 }
 ?>
\ No newline at end of file
index 370b20e..da49545 100644 (file)
@@ -539,29 +539,30 @@ class Tx_Extbase_MVC_Controller_ActionController_testcase extends Tx_Extbase_Bas
         * @author Sebastian Kurf├╝rst <sebastian@typo3.org>
         */
        public function checkRequestHashThrowsExceptionIfNeeded() {
+               // $this->markTestIncomplete('To be implemented');
                $hmacVerified = FALSE;
                $argument1Origin = Tx_Extbase_MVC_Controller_Argument::ORIGIN_PERSISTENCE_AND_MODIFIED;
                $argument2Origin = Tx_Extbase_MVC_Controller_Argument::ORIGIN_PERSISTENCE;
                $methodTagsValues = array();
-
+               
                $mockRequest = $this->getMock('Tx_Extbase_MVC_Web_Request', array('isHmacVerified'), array(), '', FALSE);
                $mockRequest->expects($this->once())->method('isHmacVerified')->will($this->returnValue($hmacVerified));
-
+               
                $argument1 = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array('getOrigin'), array(), '', FALSE);
                $argument1->expects($this->any())->method('getOrigin')->will($this->returnValue($argument1Origin));
                $argument2 = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array('getOrigin'), array(), '', FALSE);
                $argument2->expects($this->any())->method('getOrigin')->will($this->returnValue($argument2Origin));
-
+               
                $mockController = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_MVC_Controller_ActionController'), array('dummy'), array(), '', FALSE);
-
+               
                $mockReflectionService = $this->getMock('Tx_Extbase_Reflection_Service', array('getMethodTagsValues'), array(), '', FALSE);
                $mockReflectionService->expects($this->any())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
-
+               
                $mockController->_set('arguments', array($argument1, $argument2));
                $mockController->_set('request', $mockRequest);
                $mockController->_set('actionMethodName', 'fooAction');
                $mockController->injectReflectionService($mockReflectionService);
-
+               
                $mockController->_call('checkRequestHash');
        }
 
index 180c418..18726a0 100644 (file)
@@ -48,11 +48,9 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
         * @test
         */
        public function resolveValidatorObjectNameReturnsTheGivenArgumentIfAnObjectOfThatNameIsRegistered() {
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
                $validatorName = uniqid('FooValidator_') . 'Validator';
                eval('class ' . $validatorName . ' {}');
                $validatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'));
-               $validatorResolver->_set('objectManager', $mockObjectManager);
                $this->assertSame($validatorName, $validatorResolver->_call('resolveValidatorObjectName', $validatorName));
        }
 
@@ -125,7 +123,7 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
                $mockReflectionService->expects($this->once())->method('getMethodTagsValues')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodTagsValues));
                $mockReflectionService->expects($this->once())->method('getMethodParameters')->with(get_class($mockController), 'fooAction')->will($this->returnValue($methodParameters));
 
-               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'), array(), '', FALSE);
+               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'));
                $validatorResolver->injectReflectionService($mockReflectionService);
 
                $result = $validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($mockController), 'fooAction');
@@ -187,7 +185,7 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
 
                $mockArguments['arg2'] = $this->getMock('Tx_Extbase_MVC_Controller_Argument', array(), array(), '', FALSE);
 
-               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'), array(), '', FALSE);
+               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'));
                $validatorResolver->expects($this->at(0))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction1));
                $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
                $validatorResolver->expects($this->at(2))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction2));
@@ -233,7 +231,7 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
                $conjunction1 = $this->getMock('Tx_Extbase_Validation_Validator_ConjunctionValidator', array(), array(), '', FALSE);
                $conjunction1->expects($this->at(0))->method('addValidator')->with($mockStringValidator);
 
-               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'), array(), '', FALSE);
+               $validatorResolver = $this->getMock('Tx_Extbase_Validation_ValidatorResolver', array('createValidator'));
                $validatorResolver->expects($this->at(0))->method('createValidator')->with('Conjunction')->will($this->returnValue($conjunction1));
                $validatorResolver->expects($this->at(1))->method('createValidator')->with('string')->will($this->returnValue($mockStringValidator));
                $validatorResolver->expects($this->at(2))->method('createValidator')->with('F3_TestPackage_Quux')->will($this->returnValue($mockQuuxValidator));
@@ -281,7 +279,7 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
                $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface', array(), array(), '', FALSE);
                $mockObjectManager->expects($this->at(0))->method('getObject')->with('Tx_Extbase_Validation_Validator_ConjunctionValidator')->will($this->returnValue($mockConjunctionValidator));
 
-               $validatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('resolveValidatorObjectName', 'createValidator'), array($mockObjectManager));
+               $validatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('resolveValidatorObjectName', 'createValidator'));
                $validatorResolver->injectReflectionService($mockReflectionService);
                $validatorResolver->injectObjectManager($mockObjectManager);
 
@@ -301,10 +299,9 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
         * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function resolveValidatorObjectNameCallsUnifyDataType() {
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
-               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('unifyDataType'), array($mockObjectManager));
-               $mockValidator->expects($this->once())->method('unifyDataType')->with('someDataType');
-               $mockValidator->_call('resolveValidatorObjectName', 'someDataType');
+               $mockValidatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('unifyDataType'));
+               $mockValidatorResolver->expects($this->once())->method('unifyDataType')->with('someDataType');
+               $mockValidatorResolver->_call('resolveValidatorObjectName', 'someDataType');
        }
 
        /**
@@ -312,19 +309,18 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
         * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function unifyDataTypeCorrectlyRenamesPHPDataTypes() {
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
-               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'), array($mockObjectManager), '', FALSE);
-               $this->assertEquals('Integer', $mockValidator->_call('unifyDataType', 'integer'));
-               $this->assertEquals('Integer', $mockValidator->_call('unifyDataType', 'int'));
-               $this->assertEquals('String', $mockValidator->_call('unifyDataType', 'string'));
-               $this->assertEquals('Array', $mockValidator->_call('unifyDataType', 'array'));
-               $this->assertEquals('Float', $mockValidator->_call('unifyDataType', 'float'));
-               $this->assertEquals('Float', $mockValidator->_call('unifyDataType', 'double'));
-               $this->assertEquals('Boolean', $mockValidator->_call('unifyDataType', 'boolean'));
-               $this->assertEquals('Boolean', $mockValidator->_call('unifyDataType', 'bool'));
-               $this->assertEquals('Boolean', $mockValidator->_call('unifyDataType', 'bool'));
-               $this->assertEquals('Number', $mockValidator->_call('unifyDataType', 'number'));
-               $this->assertEquals('Number', $mockValidator->_call('unifyDataType', 'numeric'));
+               $mockValidatorResolver = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'));
+               $this->assertEquals('Integer', $mockValidatorResolver->_call('unifyDataType', 'integer'));
+               $this->assertEquals('Integer', $mockValidatorResolver->_call('unifyDataType', 'int'));
+               $this->assertEquals('String', $mockValidatorResolver->_call('unifyDataType', 'string'));
+               $this->assertEquals('Array', $mockValidatorResolver->_call('unifyDataType', 'array'));
+               $this->assertEquals('Float', $mockValidatorResolver->_call('unifyDataType', 'float'));
+               $this->assertEquals('Float', $mockValidatorResolver->_call('unifyDataType', 'double'));
+               $this->assertEquals('Boolean', $mockValidatorResolver->_call('unifyDataType', 'boolean'));
+               $this->assertEquals('Boolean', $mockValidatorResolver->_call('unifyDataType', 'bool'));
+               $this->assertEquals('Boolean', $mockValidatorResolver->_call('unifyDataType', 'bool'));
+               $this->assertEquals('Number', $mockValidatorResolver->_call('unifyDataType', 'number'));
+               $this->assertEquals('Number', $mockValidatorResolver->_call('unifyDataType', 'numeric'));
        }
 
        /**
@@ -332,8 +328,7 @@ class Tx_Extbase_Validation_ValidatorResolver_testcase extends Tx_Extbase_BaseTe
         * @author Bastian Waidelich <bastian@typo3.org>
         */
        public function unifyDataTypeRenamesMixedToRaw() {
-               $mockObjectManager = $this->getMock('Tx_Extbase_Object_ManagerInterface');
-               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'), array($mockObjectManager), '', FALSE);
+               $mockValidator = $this->getMock($this->buildAccessibleProxy('Tx_Extbase_Validation_ValidatorResolver'), array('dummy'));
                $this->assertEquals('Raw', $mockValidator->_call('unifyDataType', 'mixed'));
        }
 }