‪TYPO3CMS  ‪main
CliCommandTest.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\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
23 
29 {
31 
32  protected const ‪LANGUAGE_PRESETS = [
33  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
34  ];
35 
36  protected array ‪$coreExtensionsToLoad = [
37  'lowlevel',
38  'redirects',
39  'extensionmanager',
40  'scheduler',
41  'workspaces',
42  'styleguide',
43  'install',
44  ];
45 
46  public function ‪setUp(): void
47  {
48  parent::setUp();
49 
51  'show-me',
52  $this->‪buildSiteConfiguration(8000, 'https://show.me/')
53  );
54  }
55 
56  public static function ‪commandTestDataProvider(): array
57  {
58  return [
59  ['command' => 'styleguide:generate tca', 'args' => [], 'expectedExitCode' => 0],
60  ['command' => 'styleguide:generate frontend', 'args' => [], 'expectedExitCode' => 0],
61  ['command' => 'cleanup:localprocessedfiles', 'args' => ['-v'], 'expectedExitCode' => 0],
62  ['command' => 'cache:flush', 'args' => [], 'expectedExitCode' => 0],
63  ['command' => 'cache:warmup', 'args' => [], 'expectedExitCode' => 0],
64  ['command' => 'cleanup:flexforms', 'args' => [], 'expectedExitCode' => 0],
65  ['command' => 'cleanup:deletedrecords', 'args' => [], 'expectedExitCode' => 0],
66  ['command' => 'cleanup:orphanrecords', 'args' => [], 'expectedExitCode' => 0],
67  ['command' => 'cleanup:previewlinks', 'args' => [], 'expectedExitCode' => 0],
68  ['command' => 'cleanup:versions', 'args' => [], 'expectedExitCode' => 0],
69  ['command' => 'extension:list', 'args' => [], 'expectedExitCode' => 0],
70  ['command' => 'extension:setup', 'args' => [], 'expectedExitCode' => 0],
71  ['command' => 'extension:deactivate workspaces', 'args' => [], 'expectedExitCode' => 0],
72  ['command' => 'extension:activate workspaces', 'args' => [], 'expectedExitCode' => 0],
73  ['command' => 'language:update', 'args' => [], 'expectedExitCode' => 0],
74  ['command' => 'mailer:spool:send', 'args' => [], 'expectedExitCode' => 1],
75  ['command' => 'redirects:checkintegrity', 'args' => [], 'expectedExitCode' => 0],
76  ['command' => 'redirects:cleanup', 'args' => [], 'expectedExitCode' => 0],
77  ['command' => 'referenceindex:update', 'args' => ['--check'], 'expectedExitCode' => 0],
78  ['command' => 'scheduler:run', 'args' => [], 'expectedExitCode' => 0],
79  ['command' => 'site:list', 'args' => [], 'expectedExitCode' => 0],
80  ['command' => 'site:show show-me', 'args' => [], 'expectedExitCode' => 0],
81  ['command' => 'syslog:list', 'args' => [], 'expectedExitCode' => 0],
82  ['command' => 'upgrade:list', 'args' => [], 'expectedExitCode' => 0],
83  ];
84  }
85 
86  #[DataProvider('commandTestDataProvider')]
87  #[Test]
88  public function ‪cliCommand(string $command, array ‪$args, int $expectedExitCode): void
89  {
90  $result = $this->‪executeConsoleCommand($command, ...‪$args);
91 
92  self::assertEquals($expectedExitCode, $result['status']);
93  }
94 }
‪TYPO3\CMS\Core\Tests\Functional\Command\CliCommandTest
Definition: CliCommandTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:37
‪TYPO3\CMS\Core\Tests\Functional\Command\CliCommandTest\cliCommand
‪cliCommand(string $command, array $args, int $expectedExitCode)
Definition: CliCommandTest.php:87
‪TYPO3\CMS\Core\Tests\Functional\Command\CliCommandTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: CliCommandTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:50
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Core\Tests\Functional\Command\AbstractCommandTestCase\executeConsoleCommand
‪executeConsoleCommand(string $cmdline,... $args)
Definition: AbstractCommandTestCase.php:25
‪$args
‪$args
Definition: validateRstFiles.php:258
‪TYPO3\CMS\Core\Tests\Functional\Command\CliCommandTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: CliCommandTest.php:35
‪TYPO3\CMS\Core\Tests\Functional\Command\CliCommandTest\commandTestDataProvider
‪static commandTestDataProvider()
Definition: CliCommandTest.php:55
‪TYPO3\CMS\Core\Tests\Functional\Command\CliCommandTest\setUp
‪setUp()
Definition: CliCommandTest.php:45
‪TYPO3\CMS\Core\Tests\Functional\Command
Definition: AbstractCommandTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\Command\AbstractCommandTestCase
Definition: AbstractCommandTestCase.php:24