[TASK] Clean up Unit tests in fluid
authorMarkus Günther <mail@markus-guenther.de>
Sat, 9 Feb 2013 21:38:19 +0000 (22:38 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 10 Feb 2013 00:06:36 +0000 (01:06 +0100)
We had many tests in fluid that are incomplete.
These tests has been incomplete for several years.
Some test has been removed also in TYPO3 fluid.

This patch fix some test by backporting it from
TYPO3 fluid.

The rest of the incomplete tests are also
incomplete in TYPO3 fluid. Maybe we should
ask the Fluid guys.

Fixes: #45331
Releases: 6.1

Change-Id: I38789b98df1dc533b131e54e5eca0cc75b7bc5e0
Reviewed-on: https://review.typo3.org/18171
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/fluid/Tests/Unit/Core/Widget/AjaxWidgetContextHolderTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/AbstractFormFieldViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest.php

index 929e100..ec2017b 100644 (file)
@@ -27,9 +27,11 @@ class AjaxWidgetContextHolderTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTest
 
        /**
         * @test
+        * @expectedException TYPO3\CMS\Fluid\Core\Widget\Exception\WidgetContextNotFoundException
         */
-       public function foo() {
-               $this->markTestIncomplete();
+       public function getThrowsExceptionIfWidgetContextIsNotFound() {
+               $ajaxWidgetContextHolder = new \TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder();
+               $ajaxWidgetContextHolder->get(42);
        }
 }
 
index b005ae4..badad1e 100644 (file)
@@ -21,9 +21,9 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
         * @test
         */
        public function ifAnAttributeValueIsAnObjectMaintainedByThePersistenceManagerItIsConvertedToAUID() {
-               $this->markTestIncomplete('TODO - fix test in backporter');
                $mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface');
                $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('6f487e40-4483-11de-8a39-0800200c9a66'));
+
                $className = 'Object' . uniqid();
                $fullClassName = 'TYPO3\\Fluid\\ViewHelpers\\Form\\' . $className;
                eval('namespace TYPO3\\Fluid\\ViewHelpers\\Form; class ' . $className . ' {
@@ -31,12 +31,15 @@ class AbstractFormFieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHe
                }');
                $object = $this->getMock($fullClassName);
                $object->expects($this->any())->method('FLOW3_Persistence_isNew')->will($this->returnValue(FALSE));
+
                $formViewHelper = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Form\\AbstractFormFieldViewHelper', array('dummy'), array(), '', FALSE);
                $this->injectDependenciesIntoViewHelper($formViewHelper);
                $formViewHelper->injectPersistenceManager($mockPersistenceManager);
+
                $arguments = array('name' => 'foo', 'value' => $object, 'property' => NULL);
                $formViewHelper->_set('arguments', $arguments);
                $formViewHelper->expects($this->any())->method('isObjectAccessorMode')->will($this->returnValue(FALSE));
+
                $this->assertSame('foo[__identity]', $formViewHelper->_call('getName'));
                $this->assertSame('6f487e40-4483-11de-8a39-0800200c9a66', $formViewHelper->_call('getValue'));
        }
index a25d032..76d0eb6 100644 (file)
@@ -195,27 +195,31 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         * @test
         */
        public function selectOnDomainObjectsCreatesExpectedOptions() {
-               $this->markTestIncomplete('TODO - fix test in backporter');
                $mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface');
                $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue(NULL));
                $this->viewHelper->injectPersistenceManager($mockPersistenceManager);
+
                $this->tagBuilder->expects($this->once())->method('addAttribute')->with('name', 'myName');
                $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('myName');
                $this->tagBuilder->expects($this->once())->method('setContent')->with('<option value="1">Ingmar</option>' . chr(10) . '<option value="2" selected="selected">Sebastian</option>' . chr(10) . '<option value="3">Robert</option>' . chr(10));
                $this->tagBuilder->expects($this->once())->method('render');
+
                $user_is = new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\Fixture_UserDomainClass(1, 'Ingmar', 'Schlecht');
                $user_sk = new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\Fixture_UserDomainClass(2, 'Sebastian', 'Kurfuerst');
                $user_rl = new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\Fixture_UserDomainClass(3, 'Robert', 'Lemke');
+
                $this->arguments['options'] = array(
                        $user_is,
                        $user_sk,
                        $user_rl
                );
+
                $this->arguments['value'] = $user_sk;
                $this->arguments['optionValueField'] = 'id';
                $this->arguments['optionLabelField'] = 'firstName';
                $this->arguments['name'] = 'myName';
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
+
                $this->viewHelper->initialize();
                $this->viewHelper->render();
        }
@@ -280,20 +284,24 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         * @test
         */
        public function selectWithoutFurtherConfigurationOnDomainObjectsUsesUuidForValueAndLabel() {
-               $this->markTestIncomplete('TODO - fix test in backporter');
                $mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface');
-               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('fakeUID'));
+               $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('fakeUUID'));
                $this->viewHelper->injectPersistenceManager($mockPersistenceManager);
+
                $this->tagBuilder->expects($this->once())->method('addAttribute')->with('name', 'myName');
                $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('myName');
-               $this->tagBuilder->expects($this->once())->method('setContent')->with('<option value="fakeUID">fakeUID</option>' . chr(10));
+               $this->tagBuilder->expects($this->once())->method('setContent')->with('<option value="fakeUUID">fakeUUID</option>' . chr(10));
                $this->tagBuilder->expects($this->once())->method('render');
+
                $user = new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\Fixture_UserDomainClass(1, 'Ingmar', 'Schlecht');
+
                $this->arguments['options'] = array(
                        $user
                );
+
                $this->arguments['name'] = 'myName';
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
+
                $this->viewHelper->initialize();
                $this->viewHelper->render();
        }
@@ -302,21 +310,24 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         * @test
         */
        public function selectWithoutFurtherConfigurationOnDomainObjectsUsesToStringForLabelIfAvailable() {
-               $this->markTestIncomplete('TODO - fix test in backporter');
                $mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface');
                $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('fakeUID'));
                $this->viewHelper->injectPersistenceManager($mockPersistenceManager);
+
                $this->tagBuilder->expects($this->once())->method('addAttribute')->with('name', 'myName');
                $this->viewHelper->expects($this->once())->method('registerFieldNameForFormTokenGeneration')->with('myName');
                $this->tagBuilder->expects($this->once())->method('setContent')->with('<option value="fakeUID">toStringResult</option>' . chr(10));
                $this->tagBuilder->expects($this->once())->method('render');
+
                $user = $this->getMock('TYPO3\\CMS\\Fluid\\Tests\\Unit\\ViewHelpers\\Form\\Fixtures\\Fixture_UserDomainClass', array('__toString'), array(1, 'Ingmar', 'Schlecht'));
                $user->expects($this->atLeastOnce())->method('__toString')->will($this->returnValue('toStringResult'));
+
                $this->arguments['options'] = array(
                        $user
                );
                $this->arguments['name'] = 'myName';
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
+
                $this->viewHelper->initialize();
                $this->viewHelper->render();
        }
@@ -326,16 +337,18 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         * @expectedException \TYPO3\CMS\Fluid\Core\ViewHelper\Exception
         */
        public function selectOnDomainObjectsThrowsExceptionIfNoValueCanBeFound() {
-               $this->markTestIncomplete('TODO - fix test in backporter');
                $mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface');
                $mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue(NULL));
                $this->viewHelper->injectPersistenceManager($mockPersistenceManager);
+
                $user = new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\Fixture_UserDomainClass(1, 'Ingmar', 'Schlecht');
+
                $this->arguments['options'] = array(
                        $user
                );
                $this->arguments['name'] = 'myName';
                $this->injectDependenciesIntoViewHelper($this->viewHelper);
+
                $this->viewHelper->initialize();
                $this->viewHelper->render();
        }