Exemple #1
0
 /**
  * @test
  */
 public function setCommandIdentifierSetsCommandIdentifierCorrectly()
 {
     $this->task->setCommandIdentifier('Foo');
     $this->assertSame('Foo', $this->task->_get('commandIdentifier'));
 }
 /**
  * @test
  */
 public function getAdditionalFieldsRendersRightHtml()
 {
     $this->markTestSkipped('Incomplete mocking in a complex scenario. This should be a functional test');
     /** @var Command|\PHPUnit_Framework_MockObject_MockObject $command1 */
     $command1 = $this->getAccessibleMock(Command::class, array(), array(), '', false);
     $command1->expects($this->once())->method('isInternal')->will($this->returnValue(false));
     $command1->expects($this->once())->method('getControllerClassName')->will($this->returnValue(MockACommandController::class));
     $command1->expects($this->once())->method('getControllerCommandName')->will($this->returnValue('FuncA'));
     $command1->expects($this->any())->method('getCommandIdentifier')->will($this->returnValue('extbase:mocka:funca'));
     $command1->expects($this->once())->method('getArgumentDefinitions')->will($this->returnValue(array()));
     /** @var Command|\PHPUnit_Framework_MockObject_MockObject $command2 */
     $command2 = $this->getAccessibleMock(Command::class, array(), array(), '', false);
     $command2->expects($this->once())->method('isInternal')->will($this->returnValue(false));
     $command2->expects($this->once())->method('getControllerClassName')->will($this->returnValue('Acme\\Mypkg\\Command\\MockBCommandController'));
     $command2->expects($this->once())->method('getControllerCommandName')->will($this->returnValue('FuncB'));
     $command2->expects($this->any())->method('getCommandIdentifier')->will($this->returnValue('mypkg:mockb:funcb'));
     /** @var Command|\PHPUnit_Framework_MockObject_MockObject $command3 */
     $command3 = $this->getAccessibleMock(Command::class, array(), array(), '', false);
     $command3->expects($this->once())->method('isInternal')->will($this->returnValue(false));
     $command3->expects($this->once())->method('getControllerClassName')->will($this->returnValue('Tx_Extbase_Command_MockCCommandController'));
     $command3->expects($this->once())->method('getControllerCommandName')->will($this->returnValue('FuncC'));
     $command3->expects($this->any())->method('getCommandIdentifier')->will($this->returnValue('extbase:mockc:funcc'));
     /** @var CommandManager|\PHPUnit_Framework_MockObject_MockObject $commandManager */
     $commandManager = $this->getMock(CommandManager::class, array('getAvailableCommands'));
     $commandManager->expects($this->any())->method('getAvailableCommands')->will($this->returnValue(array($command1, $command2, $command3)));
     /** @var FieldProvider|\PHPUnit_Framework_MockObject_MockObject|\|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $fieldProvider */
     $fieldProvider = $this->getAccessibleMock(FieldProvider::class, array('getActionLabel', 'getArgumentLabel', 'getCommandControllerActionArgumentFields'), array(), '', false);
     $fieldProvider->_set('commandManager', $commandManager);
     $actionLabel = 'action label string';
     $argumentLabel = 'argument label string';
     $fieldProvider->expects($this->any())->method('getActionLabel')->will($this->returnValue($actionLabel));
     $fieldProvider->expects($this->any())->method('getArgumentLabel')->will($this->returnValue($argumentLabel));
     $argArray['arg'] = array('code' => '<input type="text" name="tx_scheduler[task_extbase][arguments][arg]" value="1" /> ', 'label' => $argumentLabel);
     $fieldProvider->expects($this->any())->method('getCommandControllerActionArgumentFields')->will($this->returnValue($argArray));
     $expectedAdditionalFields = array('action' => array('code' => '<select name="tx_scheduler[task_extbase][action]">' . LF . '<option title="test" value="extbase:mocka:funca" selected="selected">Extbase MockA: FuncA</option>' . LF . '<option title="test" value="mypkg:mockb:funcb">Mypkg MockB: FuncB</option>' . LF . '<option title="test" value="extbase:mockc:funcc">Extbase MockC: FuncC</option>' . LF . '</select>', 'label' => $actionLabel), 'description' => array('code' => '', 'label' => '<strong></strong>'), 'arg' => array('code' => '<input type="text" name="tx_scheduler[task_extbase][arguments][arg]" value="1" /> ', 'label' => $argumentLabel));
     $taskInfo = array();
     /** @var Task $task */
     $task = new Task();
     $task->setCommandIdentifier($command1->getCommandIdentifier());
     /** @var SchedulerModuleController $schedulerModule */
     $schedulerModule = $this->getMock(SchedulerModuleController::class, array(), array(), '', false);
     $this->assertEquals($expectedAdditionalFields, $fieldProvider->getAdditionalFields($taskInfo, $task, $schedulerModule));
 }