‪TYPO3CMS  ‪main
ExecuteSchedulableCommandAdditionalFieldProviderTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
21 use Symfony\Component\Console\Command\Command;
28 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
29 
30 final class ‪ExecuteSchedulableCommandAdditionalFieldProviderTest extends FunctionalTestCase
31 {
32  protected array ‪$coreExtensionsToLoad = ['scheduler'];
33 
34  #[Test]
36  {
37  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
38 
39  // Create a fake command and register it.
40  $command = new class () extends Command {
41  protected function configure(): void
42  {
43  $this
44  ->setName('some:test:command')
45  ->setDescription('Some test command')
46  ->addArgument('action')
47  ->addOption('action');
48  }
49  };
50  $mockCommandRegistry = $this->getMockBuilder(CommandRegistry::class)->disableOriginalConstructor()->getMock();
51  $mockCommandRegistry->method('getSchedulableCommands')->willReturn(
52  (static function () use ($command) { yield $command->getName() => $command; })()
53  );
54  GeneralUtility::setSingletonInstance(CommandRegistry::class, $mockCommandRegistry);
55 
56  $task = GeneralUtility::makeInstance(ExecuteSchedulableCommandTask::class);
57  $task->setCommandIdentifier('some:test:command');
58  $task->setDescription('Some test command');
59  $task->setArguments(['action' => '']);
60  $task->setOptions(['action' => false]);
61 
63  $taskInfo = [];
64  ‪$fields = $subject->getAdditionalFields(
65  $taskInfo,
66  $task,
67  $this->get(SchedulerModuleController::class)
68  );
69 
70  self::assertCount(3, ‪$fields);
71  self::assertTrue(isset(‪$fields['schedulableCommands'], ‪$fields['arguments_action'], ‪$fields['options_action']));
72  }
73 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandAdditionalFieldProvider
Definition: ExecuteSchedulableCommandAdditionalFieldProvider.php:40
‪TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask
Definition: ExecuteSchedulableCommandTask.php:32
‪TYPO3\CMS\Scheduler\Tests\Functional\Task\ExecuteSchedulableCommandAdditionalFieldProviderTest
Definition: ExecuteSchedulableCommandAdditionalFieldProviderTest.php:31
‪$fields
‪$fields
Definition: pages.php:5
‪TYPO3\CMS\Scheduler\Tests\Functional\Task\ExecuteSchedulableCommandAdditionalFieldProviderTest\argumentsAndOptionsWithSameNameAreAdded
‪argumentsAndOptionsWithSameNameAreAdded()
Definition: ExecuteSchedulableCommandAdditionalFieldProviderTest.php:35
‪TYPO3\CMS\Core\Console\CommandRegistry
Definition: CommandRegistry.php:31
‪TYPO3\CMS\Scheduler\Tests\Functional\Task
Definition: ExecuteSchedulableCommandAdditionalFieldProviderTest.php:18
‪TYPO3\CMS\Scheduler\Tests\Functional\Task\ExecuteSchedulableCommandAdditionalFieldProviderTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: ExecuteSchedulableCommandAdditionalFieldProviderTest.php:32
‪TYPO3\CMS\Scheduler\Controller\SchedulerModuleController
Definition: SchedulerModuleController.php:61
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52