[BUGFIX] ControllerExtensionName can not be resolved in CLI mode 10/22410/5
authorAchim Fritz <af@lightwerk.com>
Thu, 18 Jul 2013 18:35:59 +0000 (20:35 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 3 Aug 2013 21:55:21 +0000 (23:55 +0200)
This fixes the resolution of the controllerExtensionName in CLI
context.

Change-Id: Ic0363a4e1b055aff813ddf8620403df5a4fa872f
Resolves: #49288
Releases: 6.2, 6.1
Reviewed-on: https://review.typo3.org/22410
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/extbase/Classes/Mvc/Cli/Request.php
typo3/sysext/extbase/Tests/Unit/Mvc/Cli/RequestTest.php

index 06ae906..bf6f441 100644 (file)
@@ -112,19 +112,9 @@ class Request implements \TYPO3\CMS\Extbase\Mvc\RequestInterface {
         * @return void
         */
        public function setControllerObjectName($controllerObjectName) {
-               $matches = array();
-               preg_match('/
-                       ^Tx
-                       _(?P<extensionName>[^_]+)
-                       _
-                       (
-                               Command
-                       |
-                               (?P<subpackageKey>.+)_Controller
-                       )
-                       _(?P<controllerName>[a-z_]+)Controller
-                       $/ix', $controllerObjectName, $matches);
-               $this->controllerExtensionName = $matches['extensionName'];
+               $nameParts = \TYPO3\CMS\Core\Utility\ClassNamingUtility::explodeObjectControllerName($controllerObjectName);
+
+               $this->controllerExtensionName = $nameParts['extensionName'];
                $this->controllerObjectName = $controllerObjectName;
                $this->command = NULL;
        }
index 3f5a88a..4644479 100644 (file)
@@ -68,6 +68,26 @@ class RequestTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $this->mockObjectManager->expects($this->once())->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Command', 'Tx_SomeExtension_Command_BeerCommandController', 'drink');
                $this->request->getCommand();
        }
+
+       /**
+        * @test
+        */
+       public function setControllerObjectNameProperlyResolvesExtensionNameWithNamespaces() {
+               $mockCliRequest = new \TYPO3\CMS\Extbase\Mvc\Cli\Request;
+               $mockCliRequest->setControllerObjectName('TYPO3\CMS\Extbase\Command\NamespacedMockCommandController');
+
+               $this->assertSame('Extbase', $mockCliRequest->getControllerExtensionName());
+       }
+
+       /**
+        * @test
+        */
+       public function setControllerObjectNameProperlyResolvesExtensionNameWithoutNamespaces() {
+               $mockCliRequest = new \TYPO3\CMS\Extbase\Mvc\Cli\Request;
+               $mockCliRequest->setControllerObjectName('Tx_Extbase_Command_OldschoolMockCommandController');
+
+               $this->assertSame('Extbase', $mockCliRequest->getControllerExtensionName());
+       }
 }
 
 ?>
\ No newline at end of file