[BUGFIX] Fluid unit tests after namespace switch
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 25 Aug 2012 16:12:02 +0000 (18:12 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 25 Aug 2012 16:14:02 +0000 (18:14 +0200)
Change-Id: I144ea9073e9c9b25ead2aa889dc66cd56971640a
Resolves: #40200
Related: #40095
Releases: 6.0
Reviewed-on: http://review.typo3.org/14086
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/fluid/Tests/Unit/Core/Parser/TemplateParserPatternTest.php
typo3/sysext/fluid/Tests/Unit/Core/Parser/TemplateParserTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/FormFieldViewHelperBaseTestcase.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/SelectViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php

index f73ed74..3d37a1e 100644 (file)
@@ -18,8 +18,8 @@ class TemplateParserPatternTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCa
        /**
         * @test
         */
-       public function testSCAN_PATTERN_NAMESPACEDECLARATION() {
-               $pattern = str_replace('FLUID_NAMESPACE_SEPARATOR', preg_quote(\TYPO3\CMS\Fluid\Fluid::NAMESPACE_SEPARATOR), \TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_NAMESPACEDECLARATION);
+       public function testSCAN_PATTERN_LEGACYNAMESPACEDECLARATION() {
+               $pattern = str_replace('FLUID_NAMESPACE_SEPARATOR', preg_quote(\TYPO3\CMS\Fluid\Fluid::LEGACY_NAMESPACE_SEPARATOR), \TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_NAMESPACEDECLARATION);
                $this->assertEquals(preg_match($pattern, '{namespace acme=Tx_AcmeMyPackage_Bla_blubb}'), 1, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (1).');
                $this->assertEquals(preg_match($pattern, '{namespace acme=Tx_AcmeMyPackage_Bla_Blubb }'), 1, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (2).');
                $this->assertEquals(preg_match($pattern, '    {namespace foo = Tx_Foo_Bla3_Blubb }    '), 1, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (3).');
@@ -30,6 +30,18 @@ class TemplateParserPatternTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCa
        /**
         * @test
         */
+       public function testSCAN_PATTERN_NAMESPACEDECLARATION() {
+               $pattern = str_replace('FLUID_NAMESPACE_SEPARATOR', preg_quote(\TYPO3\CMS\Fluid\Fluid::NAMESPACE_SEPARATOR), \TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SCAN_PATTERN_NAMESPACEDECLARATION);
+               $this->assertEquals(preg_match($pattern, '{namespace acme=Acme.MyPackage\Bla\blubb}'), 1, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (1).');
+               $this->assertEquals(preg_match($pattern, '{namespace acme=Acme.MyPackage\Bla\Blubb }'), 1, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (2).');
+               $this->assertEquals(preg_match($pattern, '    {namespace foo = Foo\Bla3\Blubb }    '), 1, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did not match a namespace declaration (3).');
+               $this->assertEquals(preg_match($pattern, ' \\{namespace fblubb = TYPO3.Fluid\Bla3\Blubb }'), 0, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did match a namespace declaration even if it was escaped. (1)');
+               $this->assertEquals(preg_match($pattern, '\\{namespace typo3 = TYPO3.TYPO3\Bla3\Blubb }'), 0, 'The SCAN_PATTERN_NAMESPACEDECLARATION pattern did match a namespace declaration even if it was escaped. (2)');
+       }
+
+       /**
+        * @test
+        */
        public function testSPLIT_PATTERN_DYNAMICTAGS() {
                $pattern = $this->insertNamespaceIntoRegularExpression(\TYPO3\CMS\Fluid\Core\Parser\TemplateParser::$SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS, array('typo3', 't3', 'f'));
                $source = '<html><head> <f:a.testing /> <f:blablubb> {testing}</f4:blz> </t3:hi.jo>';
index 342c4f4..cde7bfb 100644 (file)
@@ -36,10 +36,10 @@ class TemplateParserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $templateParser = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser', array('dummy'));
                $templateParser->_call('extractNamespaceDefinitions', ' \\{namespace f4=F7\\Rocks} {namespace f4=Tx_Fluid_Really}');
                $expected = array(
-                       'f' => 'Tx_Fluid_ViewHelpers',
+                       'f' => 'TYPO3\CMS\Fluid\ViewHelpers',
                        'f4' => 'Tx_Fluid_Really'
                );
-               $this->assertEquals($templateParser->getNamespaces(), $expected, 'Namespaces do not match.');
+               $this->assertEquals($expected, $templateParser->getNamespaces(), 'Namespaces do not match.');
        }
 
        /**
@@ -57,8 +57,8 @@ class TemplateParserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        public function viewHelperNameWithMultipleLevelsCanBeResolvedByResolveViewHelperName() {
                $mockTemplateParser = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser', array('dummy'), array(), '', FALSE);
                $result = $mockTemplateParser->_call('resolveViewHelperName', 'f', 'foo.bar.baz');
-               $expected = 'Tx_Fluid_ViewHelpers_Foo_Bar_BazViewHelper';
-               $this->assertEquals($result, $expected, 'The name of the View Helper Name could not be resolved.');
+               $expected = 'TYPO3\CMS\Fluid\ViewHelpers\Foo\Bar\BazViewHelper';
+               $this->assertEquals($expected, $result, 'The name of the View Helper Name could not be resolved.');
        }
 
        /**
@@ -67,7 +67,7 @@ class TemplateParserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        public function viewHelperNameWithOneLevelCanBeResolvedByResolveViewHelperName() {
                $mockTemplateParser = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser', array('dummy'), array(), '', FALSE);
                $actual = $mockTemplateParser->_call('resolveViewHelperName', 'f', 'myown');
-               $expected = 'Tx_Fluid_ViewHelpers_MyownViewHelper';
+               $expected = 'TYPO3\CMS\Fluid\ViewHelpers\MyownViewHelper';
                $this->assertEquals($expected, $actual);
        }
 
@@ -201,7 +201,7 @@ class TemplateParserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockNodeOnStack = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\NodeInterface');
                $mockNodeOnStack->expects($this->once())->method('addChildNode')->with($mockViewHelperNode);
                $mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
-               $mockObjectManager->expects($this->at(0))->method('get')->with('Tx_Fluid_ViewHelpers_MyownViewHelper')->will($this->returnValue($mockViewHelper));
+               $mockObjectManager->expects($this->at(0))->method('get')->with('TYPO3\CMS\Fluid\ViewHelpers\MyownViewHelper')->will($this->returnValue($mockViewHelper));
                $mockObjectManager->expects($this->at(1))->method('create')->with('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode')->will($this->returnValue($mockViewHelperNode));
                $mockState = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\ParsingState');
                $mockState->expects($this->once())->method('getNodeFromStack')->will($this->returnValue($mockNodeOnStack));
@@ -222,7 +222,7 @@ class TemplateParserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockViewHelperNode = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', array(), array(), '', FALSE);
                $mockNodeOnStack = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\NodeInterface');
                $mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
-               $mockObjectManager->expects($this->at(0))->method('get')->with('Tx_Fluid_ViewHelpers_MyownViewHelper')->will($this->returnValue($mockViewHelper));
+               $mockObjectManager->expects($this->at(0))->method('get')->with('TYPO3\CMS\Fluid\ViewHelpers\MyownViewHelper')->will($this->returnValue($mockViewHelper));
                $mockObjectManager->expects($this->at(1))->method('create')->with('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode')->will($this->returnValue($mockViewHelperNode));
                $mockState = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\ParsingState');
                $mockState->expects($this->once())->method('getNodeFromStack')->will($this->returnValue($mockNodeOnStack));
@@ -242,7 +242,7 @@ class TemplateParserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $mockNodeOnStack = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\NodeInterface');
                $mockNodeOnStack->expects($this->once())->method('addChildNode')->with($mockViewHelperNode);
                $mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
-               $mockObjectManager->expects($this->at(0))->method('get')->with('Tx_Fluid_ViewHelpers_MyownViewHelper')->will($this->returnValue($mockViewHelper));
+               $mockObjectManager->expects($this->at(0))->method('get')->with('TYPO3\CMS\Fluid\ViewHelpers\MyownViewHelper')->will($this->returnValue($mockViewHelper));
                $mockObjectManager->expects($this->at(1))->method('create')->with('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode')->will($this->returnValue($mockViewHelperNode));
                $mockState = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\ParsingState');
                $mockState->expects($this->once())->method('getNodeFromStack')->will($this->returnValue($mockNodeOnStack));
index 886a9c3..d77c0b8 100644 (file)
@@ -44,7 +44,7 @@ abstract class FormFieldViewHelperBaseTestcase extends \TYPO3\CMS\Fluid\Tests\Un
         * @param \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper
         * @return void
         */
-       protected function injectDependenciesIntoViewHelper(\Tx_Fluid_Core_ViewHelper_AbstractViewHelper $viewHelper) {
+       protected function injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper) {
                $viewHelper->injectConfigurationManager($this->mockConfigurationManager);
                parent::injectDependenciesIntoViewHelper($viewHelper);
        }
index 6822ef7..3d2d24e 100644 (file)
@@ -199,7 +199,7 @@ class SelectViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\
         * @author Johannes K√ľnsebeck <jk@hdnet.de>
         */
        public function multipleSelectOnDomainObjectsCreatesExpectedOptionsWithoutOptionValueField() {
-               $mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface');
+               $mockPersistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\ManagerInterface');
                $mockBackend = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', array('getIdentifierByObject'), array(), '', FALSE);
                $mockBackend->expects($this->any())->method('getIdentifierByObject')->will($this->returnCallback(function ($object) {
                        return $object->getId();
index 0c4bed3..dd38e63 100644 (file)
@@ -47,7 +47,7 @@ class FormViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\ViewHel
         * @param \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper
         * @return void
         */
-       protected function injectDependenciesIntoViewHelper(\Tx_Fluid_Core_ViewHelper_AbstractViewHelper $viewHelper) {
+       protected function injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper) {
                $viewHelper->injectConfigurationManager($this->mockConfigurationManager);
                parent::injectDependenciesIntoViewHelper($viewHelper);
        }