[FEATURE] Show extensions via CLI
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Mvc / Cli / RequestBuilderTest.php
index 85fe934..32c9c8d 100644 (file)
@@ -21,19 +21,20 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Cli;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 use TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentMixingException;
+use TYPO3\CMS\Extbase\Reflection\ClassSchema;
 
 /**
  * Test case
  */
-class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
+class RequestBuilderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_Comparator_MockObject
+     * @var \TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_Comparator_MockObject
      */
     protected $requestBuilder;
 
     /**
-     * @var \TYPO3\CMS\Extbase\Mvc\Cli\Request|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
+     * @var \TYPO3\CMS\Extbase\Mvc\Cli\Request|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
      */
     protected $request;
 
@@ -53,7 +54,7 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     protected $mockCommandManager;
 
     /**
-     * @var \TYPO3\CMS\Extbase\Reflection\ReflectionService
+     * @var \TYPO3\CMS\Extbase\Reflection\ReflectionService|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $mockReflectionService;
 
@@ -67,17 +68,17 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     protected function setUp()
     {
-        $this->request = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Cli\Request::class, array('dummy'));
+        $this->request = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Cli\Request::class, ['dummy']);
         $this->mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
         $this->mockObjectManager->expects($this->any())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Cli\Request::class)->will($this->returnValue($this->request));
         $this->mockCommand = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Cli\Command::class);
-        $this->mockCommand->expects($this->any())->method('getControllerClassName')->will($this->returnValue('Tx_SomeExtensionName_Command_DefaultCommandController'));
+        $this->mockCommand->expects($this->any())->method('getControllerClassName')->will($this->returnValue('Tx\\SomeExtensionName\\Command\\DefaultCommandController'));
         $this->mockCommand->expects($this->any())->method('getControllerCommandName')->will($this->returnValue('list'));
         $this->mockCommandManager = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Cli\CommandManager::class);
         $this->mockCommandManager->expects($this->any())->method('getCommandByIdentifier')->with('some_extension_name:default:list')->will($this->returnValue($this->mockCommand));
         $this->mockReflectionService = $this->createMock(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class);
         $this->mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
-        $this->requestBuilder = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder::class, array('dummy'));
+        $this->requestBuilder = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder::class, ['dummy']);
         $this->requestBuilder->_set('objectManager', $this->mockObjectManager);
         $this->requestBuilder->_set('reflectionService', $this->mockReflectionService);
         $this->requestBuilder->_set('commandManager', $this->mockCommandManager);
@@ -89,11 +90,16 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      *
      * @test
      */
-    public function cliAccessWithExtensionControllerAndActionNameBuildsCorrectRequest()
+    public function cliAccessWithExtensionControllerAndActionNameBuildsCorrectRequest(): void
     {
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->will($this->returnValue(array()));
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => []
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
         $request = $this->requestBuilder->build('some_extension_name:default:list');
-        $this->assertSame('Tx_SomeExtensionName_Command_DefaultCommandController', $request->getControllerObjectName());
+        $this->assertSame('Tx\\SomeExtensionName\\Command\\DefaultCommandController', $request->getControllerObjectName());
         $this->assertSame('list', $request->getControllerCommandName(), 'The CLI request specifying a package, controller and action name did not return a request object pointing to the expected action.');
     }
 
@@ -106,7 +112,15 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         // mocked method ("getObjectNameByClassName") does not exist _if the mock object is not used_.
         $this->mockCommandManager->getCommandByIdentifier('some_extension_name:default:list');
         $mockCommandManager = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Cli\CommandManager::class);
-        $mockCommandManager->expects($this->any())->method('getCommandByIdentifier')->with('test:default:list')->will($this->throwException(new \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchCommandException()));
+        $mockCommandManager
+            ->expects($this->any())
+            ->method('getCommandByIdentifier')
+            ->with('test:default:list')
+            ->will(
+                $this->throwException(
+                new \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchCommandException('testing', 1476050312)
+            )
+            );
         $this->requestBuilder->_set('commandManager', $mockCommandManager);
         $request = $this->requestBuilder->build('test:default:list');
         $this->assertSame(\TYPO3\CMS\Extbase\Command\HelpCommandController::class, $request->getControllerObjectName());
@@ -115,12 +129,18 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     /**
      * @test
      */
-    public function argumentWithValueSeparatedByEqualSignBuildsCorrectRequest()
+    public function argumentWithValueSeparatedByEqualSignBuildsCorrectRequest(): void
     {
-        $methodParameters = array(
-            'testArgument' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'testArgument' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
         $request = $this->requestBuilder->build('some_extension_name:default:list --test-argument=value');
         $this->assertTrue($request->hasArgument('testArgument'), 'The given "testArgument" was not found in the built request.');
         $this->assertSame($request->getArgument('testArgument'), 'value', 'The "testArgument" had not the given value.');
@@ -131,13 +151,19 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      *
      * @test
      */
-    public function cliAccessWithExtensionControllerActionAndArgumentsBuildsCorrectRequest()
+    public function cliAccessWithExtensionControllerActionAndArgumentsBuildsCorrectRequest(): void
     {
-        $methodParameters = array(
-            'testArgument' => array('optional' => false, 'type' => 'string'),
-            'testArgument2' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'testArgument' => ['optional' => false, 'type' => 'string'],
+            'testArgument2' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
         $request = $this->requestBuilder->build('some_extension_name:default:list --test-argument=value --test-argument2=value2');
         $this->assertTrue($request->hasArgument('testArgument'), 'The given "testArgument" was not found in the built request.');
         $this->assertTrue($request->hasArgument('testArgument2'), 'The given "testArgument2" was not found in the built request.');
@@ -150,15 +176,21 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      *
      * @test
      */
-    public function checkIfCLIAccesWithPackageControllerActionAndArgumentsToleratesSpaces()
+    public function checkIfCLIAccesWithPackageControllerActionAndArgumentsToleratesSpaces(): void
     {
-        $methodParameters = array(
-            'testArgument' => array('optional' => false, 'type' => 'string'),
-            'testArgument2' => array('optional' => false, 'type' => 'string'),
-            'testArgument3' => array('optional' => false, 'type' => 'string'),
-            'testArgument4' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'testArgument' => ['optional' => false, 'type' => 'string'],
+            'testArgument2' => ['optional' => false, 'type' => 'string'],
+            'testArgument3' => ['optional' => false, 'type' => 'string'],
+            'testArgument4' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
         $request = $this->requestBuilder->build('some_extension_name:default:list --test-argument= value --test-argument2 =value2 --test-argument3 = value3 --test-argument4=value4');
         $this->assertTrue($request->hasArgument('testArgument'), 'The given "testArgument" was not found in the built request.');
         $this->assertTrue($request->hasArgument('testArgument2'), 'The given "testArgument2" was not found in the built request.');
@@ -175,14 +207,21 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      *
      * @test
      */
-    public function CLIAccesWithShortArgumentsBuildsCorrectRequest()
+    public function CLIAccesWithShortArgumentsBuildsCorrectRequest(): void
     {
-        $methodParameters = array(
-            'a' => array('optional' => false, 'type' => 'string'),
-            'd' => array('optional' => false, 'type' => 'string'),
-            'f' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'a' => ['optional' => false, 'type' => 'string'],
+            'd' => ['optional' => false, 'type' => 'string'],
+            'f' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
+
         $request = $this->requestBuilder->build('some_extension_name:default:list -d valued -f=valuef -a = valuea');
         $this->assertTrue($request->hasArgument('d'), 'The given "d" was not found in the built request.');
         $this->assertTrue($request->hasArgument('f'), 'The given "f" was not found in the built request.');
@@ -198,25 +237,32 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      *
      * @test
      */
-    public function CLIAccesWithArgumentsWithAndWithoutValuesBuildsCorrectRequest()
+    public function CLIAccesWithArgumentsWithAndWithoutValuesBuildsCorrectRequest(): void
     {
-        $methodParameters = array(
-            'testArgument' => array('optional' => false, 'type' => 'string'),
-            'testArgument2' => array('optional' => false, 'type' => 'string'),
-            'testArgument3' => array('optional' => false, 'type' => 'string'),
-            'testArgument4' => array('optional' => false, 'type' => 'string'),
-            'testArgument5' => array('optional' => false, 'type' => 'string'),
-            'testArgument6' => array('optional' => false, 'type' => 'string'),
-            'testArgument7' => array('optional' => false, 'type' => 'string'),
-            'f' => array('optional' => false, 'type' => 'string'),
-            'd' => array('optional' => false, 'type' => 'string'),
-            'a' => array('optional' => false, 'type' => 'string'),
-            'c' => array('optional' => false, 'type' => 'string'),
-            'j' => array('optional' => false, 'type' => 'string'),
-            'k' => array('optional' => false, 'type' => 'string'),
-            'm' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'testArgument' => ['optional' => false, 'type' => 'string'],
+            'testArgument2' => ['optional' => false, 'type' => 'string'],
+            'testArgument3' => ['optional' => false, 'type' => 'string'],
+            'testArgument4' => ['optional' => false, 'type' => 'string'],
+            'testArgument5' => ['optional' => false, 'type' => 'string'],
+            'testArgument6' => ['optional' => false, 'type' => 'string'],
+            'testArgument7' => ['optional' => false, 'type' => 'string'],
+            'f' => ['optional' => false, 'type' => 'string'],
+            'd' => ['optional' => false, 'type' => 'string'],
+            'a' => ['optional' => false, 'type' => 'string'],
+            'c' => ['optional' => false, 'type' => 'string'],
+            'j' => ['optional' => false, 'type' => 'string'],
+            'k' => ['optional' => false, 'type' => 'string'],
+            'm' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
+
         $request = $this->requestBuilder->build('some_extension_name:default:list --test-argument=value --test-argument2= value2 -k --test-argument-3 = value3 --test-argument4=value4 -f valuef -d=valued -a = valuea -c --testArgument7 --test-argument5 = 5 --test-argument6 -j kjk -m');
         $this->assertTrue($request->hasArgument('testArgument'), 'The given "testArgument" was not found in the built request.');
         $this->assertTrue($request->hasArgument('testArgument2'), 'The given "testArgument2" was not found in the built request.');
@@ -246,13 +292,19 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     /**
      * @test
      */
-    public function insteadOfNamedArgumentsTheArgumentsCanBePassedUnnamedInTheCorrectOrder()
+    public function insteadOfNamedArgumentsTheArgumentsCanBePassedUnnamedInTheCorrectOrder(): void
     {
-        $methodParameters = array(
-            'testArgument1' => array('optional' => false, 'type' => 'string'),
-            'testArgument2' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->exactly(2))->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'testArgument1' => ['optional' => false, 'type' => 'string'],
+            'testArgument2' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
         $request = $this->requestBuilder->build('some_extension_name:default:list --test-argument1 firstArgumentValue --test-argument2 secondArgumentValue');
         $this->assertSame('firstArgumentValue', $request->getArgument('testArgument1'));
         $this->assertSame('secondArgumentValue', $request->getArgument('testArgument2'));
@@ -264,15 +316,21 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     /**
      * @test
      */
-    public function argumentsAreDetectedAfterOptions()
+    public function argumentsAreDetectedAfterOptions(): void
     {
-        $methodParameters = array(
-            'some' => array('optional' => true, 'type' => 'boolean'),
-            'option' => array('optional' => true, 'type' => 'string'),
-            'argument1' => array('optional' => false, 'type' => 'string'),
-            'argument2' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'some' => ['optional' => true, 'type' => 'boolean'],
+            'option' => ['optional' => true, 'type' => 'string'],
+            'argument1' => ['optional' => false, 'type' => 'string'],
+            'argument2' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
         $request = $this->requestBuilder->build('some_extension_name:default:list --some -option=value file1 file2');
         $this->assertSame('list', $request->getControllerCommandName());
         $this->assertTrue($request->getArgument('some'));
@@ -283,61 +341,89 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     /**
      * @test
      */
-    public function exceedingArgumentsMayBeSpecified()
+    public function exceedingArgumentsMayBeSpecified(): void
     {
-        $methodParameters = array(
-            'testArgument1' => array('optional' => false, 'type' => 'string'),
-            'testArgument2' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
-        $expectedArguments = array('testArgument1' => 'firstArgumentValue', 'testArgument2' => 'secondArgumentValue');
+        $methodParameters = [
+            'testArgument1' => ['optional' => false, 'type' => 'string'],
+            'testArgument2' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
+
+        $expectedArguments = ['testArgument1' => 'firstArgumentValue', 'testArgument2' => 'secondArgumentValue'];
         $request = $this->requestBuilder->build('some_extension_name:default:list --test-argument1=firstArgumentValue --test-argument2 secondArgumentValue exceedingArgument1');
         $this->assertEquals($expectedArguments, $request->getArguments());
-        $this->assertEquals(array('exceedingArgument1'), $request->getExceedingArguments());
+        $this->assertEquals(['exceedingArgument1'], $request->getExceedingArguments());
     }
 
     /**
      * @test
      */
-    public function ifNamedArgumentsAreUsedAllRequiredArgumentsMustBeNamed()
+    public function ifNamedArgumentsAreUsedAllRequiredArgumentsMustBeNamed(): void
     {
         $this->expectException(InvalidArgumentMixingException::class);
         $this->expectExceptionCode(1309971820);
-        $methodParameters = array(
-            'testArgument1' => array('optional' => false, 'type' => 'string'),
-            'testArgument2' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'testArgument1' => ['optional' => false, 'type' => 'string'],
+            'testArgument2' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
+
         $this->requestBuilder->build('some_extension_name:default:list --test-argument1 firstArgumentValue secondArgumentValue');
     }
 
     /**
      * @test
      */
-    public function ifUnnamedArgumentsAreUsedAllRequiredArgumentsMustBeUnnamed()
+    public function ifUnnamedArgumentsAreUsedAllRequiredArgumentsMustBeUnnamed(): void
     {
         $this->expectException(InvalidArgumentMixingException::class);
         $this->expectExceptionCode(1309971821);
-        $methodParameters = array(
-            'requiredArgument1' => array('optional' => false, 'type' => 'string'),
-            'requiredArgument2' => array('optional' => false, 'type' => 'string')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
+        $methodParameters = [
+            'requiredArgument1' => ['optional' => false, 'type' => 'string'],
+            'requiredArgument2' => ['optional' => false, 'type' => 'string']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
+
         $this->requestBuilder->build('some_extension_name:default:list firstArgumentValue --required-argument2 secondArgumentValue');
     }
 
     /**
      * @test
      */
-    public function booleanOptionsAreConsideredEvenIfAnUnnamedArgumentFollows()
+    public function booleanOptionsAreConsideredEvenIfAnUnnamedArgumentFollows(): void
     {
-        $methodParameters = array(
-            'requiredArgument1' => array('optional' => false, 'type' => 'string'),
-            'requiredArgument2' => array('optional' => false, 'type' => 'string'),
-            'booleanOption' => array('optional' => true, 'type' => 'boolean')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
-        $expectedArguments = array('requiredArgument1' => 'firstArgumentValue', 'requiredArgument2' => 'secondArgumentValue', 'booleanOption' => true);
+        $methodParameters = [
+            'requiredArgument1' => ['optional' => false, 'type' => 'string'],
+            'requiredArgument2' => ['optional' => false, 'type' => 'string'],
+            'booleanOption' => ['optional' => true, 'type' => 'boolean']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
+
+        $expectedArguments = ['requiredArgument1' => 'firstArgumentValue', 'requiredArgument2' => 'secondArgumentValue', 'booleanOption' => true];
         $request = $this->requestBuilder->build('some_extension_name:default:list --booleanOption firstArgumentValue secondArgumentValue');
         $this->assertEquals($expectedArguments, $request->getArguments());
     }
@@ -345,18 +431,25 @@ class RequestBuilderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     /**
      * @test
      */
-    public function booleanOptionsCanHaveOnlyCertainValuesIfTheValueIsAssignedWithoutEqualSign()
+    public function booleanOptionsCanHaveOnlyCertainValuesIfTheValueIsAssignedWithoutEqualSign(): void
     {
-        $methodParameters = array(
-            'b1' => array('optional' => true, 'type' => 'boolean'),
-            'b2' => array('optional' => true, 'type' => 'boolean'),
-            'b3' => array('optional' => true, 'type' => 'boolean'),
-            'b4' => array('optional' => true, 'type' => 'boolean'),
-            'b5' => array('optional' => true, 'type' => 'boolean'),
-            'b6' => array('optional' => true, 'type' => 'boolean')
-        );
-        $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Tx_SomeExtensionName_Command_DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
-        $expectedArguments = array('b1' => true, 'b2' => true, 'b3' => true, 'b4' => false, 'b5' => false, 'b6' => false);
+        $methodParameters = [
+            'b1' => ['optional' => true, 'type' => 'boolean'],
+            'b2' => ['optional' => true, 'type' => 'boolean'],
+            'b3' => ['optional' => true, 'type' => 'boolean'],
+            'b4' => ['optional' => true, 'type' => 'boolean'],
+            'b5' => ['optional' => true, 'type' => 'boolean'],
+            'b6' => ['optional' => true, 'type' => 'boolean']
+        ];
+
+        $classSchemaMock = $this->createMock(ClassSchema::class);
+        $classSchemaMock->expects($this->any())->method('getMethod')->with('listCommand')->willReturn([
+            'params' => $methodParameters
+        ]);
+
+        $this->mockReflectionService->expects($this->any())->method('getClassSchema')->with('Tx\\SomeExtensionName\\Command\\DefaultCommandController')->willReturn($classSchemaMock);
+
+        $expectedArguments = ['b1' => true, 'b2' => true, 'b3' => true, 'b4' => false, 'b5' => false, 'b6' => false];
         $request = $this->requestBuilder->build('some_extension_name:default:list --b2 y --b1 1 --b3 true --b4 false --b5 n --b6 0');
         $this->assertEquals($expectedArguments, $request->getArguments());
     }