[BUGFIX] Enable skipped tests by properly creating mocks 28/31228/2
authorHelmut Hummel <helmut.hummel@typo3.org>
Sun, 29 Jun 2014 14:39:29 +0000 (16:39 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sun, 29 Jun 2014 15:03:29 +0000 (17:03 +0200)
Latest changes in PHP disallow unserialize on
certain internal classes. Since phpunit uses
unserialize to create objects of such classes
when requesting a mock without calling the constructor
these tests failed with a PHP fatal error.

Instead of skipping the tests, we can simply provide
mocked constructor arguments (if required) so that
phpunit can create a mock object by using the new operator
and passing these mocked constructor arguments.

Releases: 6.3, 6.2
Resolves: #59981
Related: #59685
Change-Id: Ibd3b9aee0376a5043e053cffa6c88f7b93c86e18
Reviewed-on: https://review.typo3.org/31228
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/AbstractControllerTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ActionControllerTest.php

index a0e8670..56ac975 100644 (file)
@@ -100,13 +100,10 @@ class AbstractControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @dataProvider addFlashMessageDataProvider
         */
        public function addFlashMessageAddsFlashMessageObjectToFlashMessageQueue($expectedMessage, $messageBody, $messageTitle = '', $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK, $storeInSession = TRUE) {
-               $this->markTestSkipped('Triggers "UnexpectedValueException: Serialized string cannot be empty", with phpunit since PHP in 5.4.29 and 5.5.13, needs investigation, see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/178');
                $flashMessageQueue = $this->getMock(
                        'TYPO3\\CMS\\Core\\Messaging\\FlashMessageQueue',
                        array('enqueue'),
-                       array(),
-                       '',
-                       FALSE
+                       array(uniqid('identifier_', TRUE))
                );
                $flashMessageQueue->expects($this->once())->method('enqueue')->with($this->equalTo($expectedMessage));
 
index d00063d..e9590f2 100644 (file)
@@ -306,9 +306,8 @@ class ActionControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @author Robert Lemke <robert@typo3.org>
         */
        public function initializeActionMethodArgumentsRegistersArgumentsFoundInTheSignatureOfTheCurrentActionMethod() {
-               $this->markTestSkipped('Triggers "UnexpectedValueException: Serialized string cannot be empty", with phpunit since PHP in 5.4.29 and 5.5.13, needs investigation, see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/178');
                $mockRequest = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Request', array(), array(), '', FALSE);
-               $mockArguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('addNewArgument', 'removeAll'), array(), '', FALSE);
+               $mockArguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('addNewArgument', 'removeAll'));
                $mockArguments->expects($this->at(0))->method('addNewArgument')->with('stringArgument', 'string', TRUE);
                $mockArguments->expects($this->at(1))->method('addNewArgument')->with('integerArgument', 'integer', TRUE);
                $mockArguments->expects($this->at(2))->method('addNewArgument')->with('objectArgument', 'F3_Foo_Bar', TRUE);
@@ -427,12 +426,11 @@ class ActionControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @author Sebastian Kurfürst <sbastian@typo3.org>
         */
        public function initializeActionMethodValidatorsCorrectlyRegistersValidatorsBasedOnDataType() {
-               $this->markTestSkipped('Triggers "UnexpectedValueException: Serialized string cannot be empty", with phpunit since PHP in 5.4.29 and 5.5.13, needs investigation, see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/178');
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction'), array(), '', FALSE);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $argument = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array('getName'), array(), '', FALSE);
                $argument->expects($this->any())->method('getName')->will($this->returnValue('arg1'));
-               $arguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('dummy'), array(), '', FALSE);
+               $arguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('dummy'));
                $arguments->addArgument($argument);
                $methodTagsValues = array();
                $methodArgumentsValidatorConjunctions = array();
@@ -454,13 +452,12 @@ class ActionControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @author Sebastian Kurfürst <sbastian@typo3.org>
         */
        public function initializeActionMethodValidatorsRegistersModelBasedValidators() {
-               $this->markTestSkipped('Triggers "UnexpectedValueException: Serialized string cannot be empty", with phpunit since PHP in 5.4.29 and 5.5.13, needs investigation, see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/178');
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction'), array(), '', FALSE);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $argument = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array('getName', 'getDataType'), array(), '', FALSE);
                $argument->expects($this->any())->method('getName')->will($this->returnValue('arg1'));
                $argument->expects($this->any())->method('getDataType')->will($this->returnValue('F3_Foo_Quux'));
-               $arguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('dummy'), array(), '', FALSE);
+               $arguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('dummy'));
                $arguments->addArgument($argument);
                $methodTagsValues = array();
                $quuxBaseValidatorConjunction = $this->getMock('TYPO3\\CMS\\Extbase\\Validation\\Validator\\ConjunctionValidator', array(), array(), '', FALSE);
@@ -485,13 +482,12 @@ class ActionControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @author Sebastian Kurfürst <sbastian@typo3.org>
         */
        public function initializeActionMethodValidatorsDoesNotRegisterModelBasedValidatorsIfDontValidateAnnotationIsSet() {
-               $this->markTestSkipped('Triggers "UnexpectedValueException: Serialized string cannot be empty", with phpunit since PHP in 5.4.29 and 5.5.13, needs investigation, see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/178');
                $mockController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ActionController', array('fooAction'), array(), '', FALSE);
                $this->enableDeprecatedPropertyMapperInController($mockController);
                $argument = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array('getName', 'getDataType'), array(), '', FALSE);
                $argument->expects($this->any())->method('getName')->will($this->returnValue('arg1'));
                $argument->expects($this->any())->method('getDataType')->will($this->returnValue('F3_Foo_Quux'));
-               $arguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('dummy'), array(), '', FALSE);
+               $arguments = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Arguments', array('dummy'));
                $arguments->addArgument($argument);
                $methodTagsValues = array(
                        'dontvalidate' => array(