‪TYPO3CMS  ‪main
TextDescriptorTest.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\Application;
22 use Symfony\Component\Console\Output\OutputInterface;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
27 final class ‪TextDescriptorTest extends UnitTestCase
28 {
29  #[Test]
31  {
32  $commandRegistry = $this->createMock(CommandRegistry::class);
33  $commandRegistry
34  ->method('filter')
35  ->willReturn([
36  'command1' => [
37  'name' => 'command1',
38  'description' => 'description1',
39  ],
40  'command2' => [
41  'name' => 'command2',
42  ],
43  ]);
44 
45  ‪$output = $this->createMock(OutputInterface::class);
46 
47  $matcher = self::exactly(2);
49  ->expects($matcher)
50  ->method('write')
51  ->willReturnCallback(function (string $description) use ($matcher) {
52  match ($matcher->numberOfInvocations()) {
53  1 => self::assertEquals("command1 description1\n", $description),
54  2 => self::assertEquals("command2 \n", $description),
55  default => self::fail('Unexpected number of invocations')
56  };
57  });
58 
59  $subject = $this->getAccessibleMock(TextDescriptor::class, null, [$commandRegistry, false]);
60  $subject->_set('output', ‪$output);
61  $subject->_call(
62  'describeApplication',
63  $this->createMock(Application::class),
64  ['raw_text' => true]
65  );
66  }
67 }
‪TYPO3\CMS\Core\Tests\Unit\Command\Descriptor\TextDescriptorTest\ensureEmptyStringIsSetForDescriptionIfNoDescriptionForCommandIsGiven
‪ensureEmptyStringIsSetForDescriptionIfNoDescriptionForCommandIsGiven()
Definition: TextDescriptorTest.php:30
‪TYPO3\CMS\Core\Console\CommandRegistry
Definition: CommandRegistry.php:31
‪TYPO3\CMS\Core\Tests\Unit\Command\Descriptor\TextDescriptorTest
Definition: TextDescriptorTest.php:28
‪$output
‪$output
Definition: annotationChecker.php:114
‪TYPO3\CMS\Core\Tests\Unit\Command\Descriptor
Definition: TextDescriptorTest.php:18
‪TYPO3\CMS\Core\Command\Descriptor\TextDescriptor
Definition: TextDescriptor.php:33