24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
38 $command1 = $this->getAccessibleMock(Command::class, [], [],
'',
false);
39 $command1->expects($this->once())->method(
'isInternal')->will($this->returnValue(
false));
40 $command1->expects($this->once())->method(
'isCliOnly')->will($this->returnValue(
false));
41 $command1->expects($this->once())->method(
'getControllerClassName')->will($this->returnValue(MockACommandController::class));
42 $command1->expects($this->once())->method(
'getControllerCommandName')->will($this->returnValue(
'FuncA'));
43 $command1->expects($this->once())->method(
'getCommandIdentifier')->will($this->returnValue(
'extbase:mocka:funca'));
46 $command2 = $this->getAccessibleMock(Command::class, [], [],
'',
false);
47 $command2->expects($this->once())->method(
'isInternal')->will($this->returnValue(
false));
48 $command2->expects($this->once())->method(
'isCliOnly')->will($this->returnValue(
false));
49 $command2->expects($this->once())->method(
'getControllerClassName')->will($this->returnValue(
'Acme\\Mypkg\\Command\\MockBCommandController'));
50 $command2->expects($this->once())->method(
'getControllerCommandName')->will($this->returnValue(
'FuncB'));
51 $command2->expects($this->once())->method(
'getCommandIdentifier')->will($this->returnValue(
'mypkg:mockb:funcb'));
54 $commandManager = $this->getMockBuilder(CommandManager::class)
55 ->setMethods([
'getAvailableCommands'])
57 $commandManager->expects($this->any())->method(
'getAvailableCommands')->will($this->returnValue([$command1, $command2]));
60 $fieldProvider = $this->getAccessibleMock(
67 $fieldProvider->_set(
'commandManager', $commandManager);
68 $fieldProvider->expects($this->once())->method(
'getActionLabel')->will($this->returnValue(
'some label'));
69 $actualResult = $fieldProvider->_call(
'getCommandControllerActionField', []);
70 $this->assertContains(
'<option title="test" value="extbase:mocka:funca">Extbase MockA: FuncA</option>', $actualResult[
'code']);
71 $this->assertContains(
'<option title="test" value="mypkg:mockb:funcb">Mypkg MockB: FuncB</option>', $actualResult[
'code']);
80 $command = $this->getAccessibleMock(Command::class, [], [],
'',
false);
81 $command->method(
'isInternal')->will($this->returnValue(
true));
82 $command->method(
'isCliOnly')->will($this->returnValue(
false));
83 $command->method(
'getControllerClassName')->will($this->returnValue(MockACommandController::class));
84 $command->method(
'getControllerCommandName')->will($this->returnValue(
'FuncA'));
85 $command->method(
'getCommandIdentifier')->will($this->returnValue(
'extbase:mocka:funca'));
88 $commandManager = $this->getMockBuilder(CommandManager::class)
89 ->setMethods([
'getAvailableCommands'])
91 $commandManager->expects($this->any())->method(
'getAvailableCommands')->will($this->returnValue([$command]));
94 $fieldProvider = $this->getAccessibleMock(
101 $fieldProvider->_set(
'commandManager', $commandManager);
102 $fieldProvider->expects($this->once())->method(
'getActionLabel')->will($this->returnValue(
'some label'));
103 $actualResult = $fieldProvider->_call(
'getCommandControllerActionField', []);
104 $this->assertNotContains(
'<option title="test" value="extbase:mocka:funca">Extbase MockA: FuncA</option>', $actualResult[
'code']);
113 $command = $this->getAccessibleMock(Command::class, [], [],
'',
false);
114 $command->method(
'isInternal')->will($this->returnValue(
false));
115 $command->method(
'isCliOnly')->will($this->returnValue(
true));
116 $command->method(
'getControllerClassName')->will($this->returnValue(MockACommandController::class));
117 $command->method(
'getControllerCommandName')->will($this->returnValue(
'FuncA'));
118 $command->method(
'getCommandIdentifier')->will($this->returnValue(
'extbase:mocka:funca'));
121 $commandManager = $this->getMockBuilder(CommandManager::class)
122 ->setMethods([
'getAvailableCommands'])
124 $commandManager->expects($this->any())->method(
'getAvailableCommands')->will($this->returnValue([$command]));
127 $fieldProvider = $this->getAccessibleMock(
128 FieldProvider::class,
134 $fieldProvider->_set(
'commandManager', $commandManager);
135 $fieldProvider->expects($this->once())->method(
'getActionLabel')->will($this->returnValue(
'some label'));
136 $actualResult = $fieldProvider->_call(
'getCommandControllerActionField', []);
137 $this->assertNotContains(
'<option title="test" value="extbase:mocka:funca">Extbase MockA: FuncA</option>', $actualResult[
'code']);
146 $expectedResult =
'Extbase';
147 $actualResult = $mockController->getExtensionName();
148 $this->assertSame($expectedResult, $actualResult);
157 $fieldProvider = $this->getAccessibleMock(
158 FieldProvider::class,
166 $schedulerModule = $this->createMock(SchedulerModuleController::class);
167 $this->assertTrue($fieldProvider->validateAdditionalFields($submittedData, $schedulerModule));
175 $this->markTestSkipped(
'Incomplete mocking in a complex scenario. This should be a functional test');
178 $command1 = $this->getAccessibleMock(Command::class, [], [],
'',
false);
179 $command1->expects($this->once())->method(
'isInternal')->will($this->returnValue(
false));
180 $command1->expects($this->once())->method(
'getControllerClassName')->will($this->returnValue(MockACommandController::class));
181 $command1->expects($this->once())->method(
'getControllerCommandName')->will($this->returnValue(
'FuncA'));
182 $command1->expects($this->any())->method(
'getCommandIdentifier')->will($this->returnValue(
'extbase:mocka:funca'));
183 $command1->expects($this->once())->method(
'getArgumentDefinitions')->will($this->returnValue([]));
186 $command2 = $this->getAccessibleMock(Command::class, [], [],
'',
false);
187 $command2->expects($this->once())->method(
'isInternal')->will($this->returnValue(
false));
188 $command2->expects($this->once())->method(
'getControllerClassName')->will($this->returnValue(
'Acme\\Mypkg\\Command\\MockBCommandController'));
189 $command2->expects($this->once())->method(
'getControllerCommandName')->will($this->returnValue(
'FuncB'));
190 $command2->expects($this->any())->method(
'getCommandIdentifier')->will($this->returnValue(
'mypkg:mockb:funcb'));
193 $command3 = $this->getAccessibleMock(Command::class, [], [],
'',
false);
194 $command3->expects($this->once())->method(
'isInternal')->will($this->returnValue(
false));
195 $command3->expects($this->once())->method(
'getControllerClassName')->will($this->returnValue(
'Tx_Extbase_Command_MockCCommandController'));
196 $command3->expects($this->once())->method(
'getControllerCommandName')->will($this->returnValue(
'FuncC'));
197 $command3->expects($this->any())->method(
'getCommandIdentifier')->will($this->returnValue(
'extbase:mockc:funcc'));
200 $commandManager = $this->getMockBuilder(CommandManager::class)
201 ->setMethods([
'getAvailableCommands'])
203 $commandManager->expects($this->any())->method(
'getAvailableCommands')->will($this->returnValue([$command1, $command2, $command3]));
206 $fieldProvider = $this->getAccessibleMock(
207 FieldProvider::class,
208 [
'getActionLabel',
'getArgumentLabel',
'getCommandControllerActionArgumentFields'],
213 $fieldProvider->_set(
'commandManager', $commandManager);
214 $actionLabel =
'action label string';
215 $argumentLabel =
'argument label string';
216 $fieldProvider->expects($this->any())->method(
'getActionLabel')->will($this->returnValue($actionLabel));
217 $fieldProvider->expects($this->any())->method(
'getArgumentLabel')->will($this->returnValue($argumentLabel));
219 'code' =>
'<input type="text" name="tx_scheduler[task_extbase][arguments][arg]" value="1" /> ',
220 'label' => $argumentLabel
222 $fieldProvider->expects($this->any())->method(
'getCommandControllerActionArgumentFields')->will($this->returnValue($argArray));
223 $expectedAdditionalFields = [
225 'code' =>
'<select name="tx_scheduler[task_extbase][action]">' . LF
226 .
'<option title="test" value="extbase:mocka:funca" selected="selected">Extbase MockA: FuncA</option>' . LF
227 .
'<option title="test" value="mypkg:mockb:funcb">Mypkg MockB: FuncB</option>' . LF
228 .
'<option title="test" value="extbase:mockc:funcc">Extbase MockC: FuncC</option>' . LF
230 'label' => $actionLabel
234 'label' =>
'<strong></strong>'
237 'code' =>
'<input type="text" name="tx_scheduler[task_extbase][arguments][arg]" value="1" /> ',
238 'label' => $argumentLabel
245 $task->setCommandIdentifier($command1->getCommandIdentifier());
247 $schedulerModule = $this->createMock(SchedulerModuleController::class);
249 $this->assertEquals($expectedAdditionalFields, $fieldProvider->getAdditionalFields($taskInfo, $task, $schedulerModule));