From 846286efa9d90a0637fda87fd2c3c446897db454 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:24:15 +0200 Subject: [PATCH 1/7] ordered_imports --- tests/ApplicationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ApplicationTest.php b/tests/ApplicationTest.php index fce3f2ad..764c0c6d 100644 --- a/tests/ApplicationTest.php +++ b/tests/ApplicationTest.php @@ -25,8 +25,8 @@ use Joomla\Console\Tests\Fixtures\Command\TopNamespacedCommand; use Joomla\Event\Dispatcher; use Joomla\Test\TestHelper; -use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; use Symfony\Component\Console\Exception\CommandNotFoundException; From cdf9acd55345194506fffa03ac67c8c61f1b2953 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:26:11 +0200 Subject: [PATCH 2/7] convert metadata doc-comment to attribute --- tests/ApplicationTest.php | 191 +++----------------------- tests/Command/AbstractCommandTest.php | 38 +---- tests/Command/HelpCommandTest.php | 27 ++-- tests/Command/ListCommandTest.php | 32 ++--- tests/Loader/ContainerLoaderTest.php | 15 +- 5 files changed, 54 insertions(+), 249 deletions(-) diff --git a/tests/ApplicationTest.php b/tests/ApplicationTest.php index 764c0c6d..84ecc5d6 100644 --- a/tests/ApplicationTest.php +++ b/tests/ApplicationTest.php @@ -12,10 +12,15 @@ use Joomla\Console\Command\HelpCommand; use Joomla\Console\Command\ListCommand; use Joomla\Console\ConsoleEvents; +use Joomla\Console\Descriptor\ApplicationDescription; +use Joomla\Console\Descriptor\TextDescriptor; use Joomla\Console\Event\ApplicationErrorEvent; use Joomla\Console\Event\BeforeCommandExecuteEvent; use Joomla\Console\Event\CommandErrorEvent; +use Joomla\Console\Event\ConsoleEvent; +use Joomla\Console\Event\TerminateEvent; use Joomla\Console\Exception\NamespaceNotFoundException; +use Joomla\Console\Helper\DescriptorHelper; use Joomla\Console\Loader\ContainerLoader; use Joomla\Console\Tests\Fixtures\Command\AliasedCommand; use Joomla\Console\Tests\Fixtures\Command\AnonymousCommand; @@ -25,7 +30,9 @@ use Joomla\Console\Tests\Fixtures\Command\TopNamespacedCommand; use Joomla\Event\Dispatcher; use Joomla\Test\TestHelper; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; @@ -40,6 +47,19 @@ /** * Test class for \Joomla\Console\Application */ +#[CoversClass(Application::class)] +#[UsesClass(AbstractCommand::class)] +#[UsesClass(HelpCommand::class)] +#[UsesClass(ListCommand::class)] +#[UsesClass(ApplicationDescription::class)] +#[UsesClass(TextDescriptor::class)] +#[UsesClass(ApplicationErrorEvent::class)] +#[UsesClass(BeforeCommandExecuteEvent::class)] +#[UsesClass(CommandErrorEvent::class)] +#[UsesClass(ConsoleEvent::class)] +#[UsesClass(TerminateEvent::class)] +#[UsesClass(DescriptorHelper::class)] +#[UsesClass(ContainerLoader::class)] class ApplicationTest extends TestCase { /** @@ -58,15 +78,6 @@ protected function setUp(): void $this->object = new Application(); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Descriptor\ApplicationDescription - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testTheApplicationIsExecutedWithTheDefaultCommand() { $input = new ArrayInput([]); @@ -79,15 +90,6 @@ public function testTheApplicationIsExecutedWithTheDefaultCommand() $this->assertNotEmpty($output->fetch()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Descriptor\ApplicationDescription - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testTheApplicationIsExecutedWithTheRequestedCommand() { $input = new ArrayInput( @@ -104,15 +106,6 @@ public function testTheApplicationIsExecutedWithTheRequestedCommand() $this->assertNotEmpty($output->fetch()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Descriptor\ApplicationDescription - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testTheApplicationPrintsTheVersionInformation() { $input = new ArrayInput( @@ -131,18 +124,12 @@ public function testTheApplicationPrintsTheVersionInformation() $this->assertSame('Console Tester 1.0.0', trim($output->fetch())); } - /** - * @covers Joomla\Console\Application - */ public function testSetGetName() { $this->object->setName('Console Application'); $this->assertSame('Console Application', $this->object->getName()); } - /** - * @covers Joomla\Console\Application - */ public function testSetGetVersion() { $this->object->setVersion('1.0.0'); @@ -169,10 +156,6 @@ public static function dataGetLongVersionProvider(): array * @param string $name Application name * @param string $version Application version * @param string $expected Expected return - * - * @covers Joomla\Console\Application - * - * @dataProvider dataGetLongVersion */ #[DataProvider('dataGetLongVersionProvider')] public function testGetLongVersion(string $name, string $version, string $expected) @@ -182,12 +165,6 @@ public function testGetLongVersion(string $name, string $version, string $expect $this->assertSame($expected, $this->object->getLongVersion()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testGetAllCommands() { $commands = $this->object->getAllCommands(); @@ -199,13 +176,6 @@ public function testGetAllCommands() $this->assertCount(1, $commands); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Loader\ContainerLoader - */ public function testGetAllCommandsWithCommandLoader() { $commands = $this->object->getAllCommands(); @@ -231,12 +201,6 @@ function (ContainerInterface $container) { $this->assertCount(2, $commands); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testAddHasCommand() { $this->object->addCommand(new NamespacedCommand()); @@ -246,12 +210,6 @@ public function testAddHasCommand() $this->assertFalse($this->object->hasCommand('test:disabled')); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testAddCommandWithBrokenConstructor() { $this->expectException(LogicException::class); @@ -260,12 +218,6 @@ public function testAddCommandWithBrokenConstructor() $this->object->addCommand(new SkipConfigurationCommand()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testAddCommandWithNoName() { $this->expectException(LogicException::class); @@ -274,12 +226,6 @@ public function testAddCommandWithNoName() $this->object->addCommand(new AnonymousCommand()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testHasGetCommand() { $this->assertTrue($this->object->hasCommand('list')); @@ -306,13 +252,6 @@ public function testHasGetCommand() ); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Loader\ContainerLoader - */ public function testHasGetCommandWithCommandLoader() { $this->assertTrue($this->object->hasCommand('list')); @@ -333,12 +272,6 @@ function (ContainerInterface $container) { $this->assertInstanceOf(NamespacedCommand::class, $this->object->getCommand('test:namespaced')); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testGetCommandForUnknownCommand() { $this->expectException(CommandNotFoundException::class); @@ -347,12 +280,6 @@ public function testGetCommandForUnknownCommand() $this->object->getCommand('test'); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testGetNamespaces() { $this->object->addCommand(new NamespacedCommand()); @@ -361,12 +288,6 @@ public function testGetNamespaces() $this->assertEquals(['test'], $this->object->getNamespaces()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testFindNamespace() { $this->object->addCommand(new NamespacedCommand()); @@ -381,12 +302,6 @@ public function testFindNamespace() $this->assertEquals('test', $this->object->findNamespace('test')); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testFindAmbiguousNamespace() { $this->expectException(NamespaceNotFoundException::class); @@ -398,12 +313,6 @@ public function testFindAmbiguousNamespace() $this->object->findNamespace('t'); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - */ public function testFindUnknownNamespace() { $this->expectException(NamespaceNotFoundException::class); @@ -412,14 +321,6 @@ public function testFindUnknownNamespace() $this->object->findNamespace('test'); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testNoOutputWhenHelpRequestedWithQuietFlag() { $input = new ArrayInput( @@ -437,15 +338,6 @@ public function testNoOutputWhenHelpRequestedWithQuietFlag() $this->assertEmpty($output->fetch()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Event\ApplicationErrorEvent - * @uses Joomla\Console\Event\CommandErrorEvent - * @uses Joomla\Console\Event\ConsoleEvent - */ public function testHandlingThrowables() { $input = new ArrayInput( @@ -475,15 +367,6 @@ public function testHandlingThrowables() } } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Descriptor\ApplicationDescription - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testAppIsClosedWhenAutoExitIsEnabled() { $input = new ArrayInput( @@ -501,15 +384,6 @@ public function testAppIsClosedWhenAutoExitIsEnabled() $this->assertTrue($app->wasClosed()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Event\ApplicationErrorEvent - * @uses Joomla\Console\Event\CommandErrorEvent - * @uses Joomla\Console\Event\ConsoleEvent - */ public function testExitCodeIsSetByEventListener() { $dispatcher = new Dispatcher(); @@ -536,14 +410,6 @@ function (ApplicationErrorEvent $event) { $this->assertSame(119, $app->getExitCode()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Event\CommandErrorEvent - * @uses Joomla\Console\Event\ConsoleEvent - */ public function testCommandNotFoundHasSuccessExitIfEventListenerSpecifiesSo() { $dispatcher = new Dispatcher(); @@ -570,14 +436,6 @@ function (CommandErrorEvent $event) { $this->assertSame(0, $app->getExitCode()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Event\ApplicationErrorEvent - * @uses Joomla\Console\Event\ConsoleEvent - */ public function testCommandErrorHasExitCodeOneIfExceptionHasCodeZero() { $command = new class () extends AbstractCommand { @@ -605,15 +463,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertSame(1, $app->getExitCode()); } - /** - * @covers Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Event\BeforeCommandExecuteEvent - * @uses Joomla\Console\Event\ConsoleEvent - * @uses Joomla\Console\Event\TerminateEvent - */ public function testCommandIsNotExecutedIfEventSkipsCommand() { $command = new class () extends AbstractCommand { diff --git a/tests/Command/AbstractCommandTest.php b/tests/Command/AbstractCommandTest.php index d1d8ed8b..572f0e33 100644 --- a/tests/Command/AbstractCommandTest.php +++ b/tests/Command/AbstractCommandTest.php @@ -9,6 +9,8 @@ use Joomla\Console\Application; use Joomla\Console\Command\AbstractCommand; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; @@ -19,11 +21,10 @@ /** * Test class for \Joomla\Console\Command\AbstractCommand */ +#[CoversClass(AbstractCommand::class)] +#[UsesClass(Application::class)] class AbstractCommandTest extends TestCase { - /** - * @covers Joomla\Console\Command\AbstractCommand - */ public function testTheCommandIsExecutedWithoutAnApplication() { $command = new class () extends AbstractCommand { @@ -39,10 +40,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertSame(0, $command->execute($input, $output)); } - /** - * @covers Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Application - */ public function testTheCommandIsExecutedWithAnApplication() { $command = new class () extends AbstractCommand { @@ -62,9 +59,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertSame(0, $command->execute($input, $output)); } - /** - * @covers Joomla\Console\Command\AbstractCommand - */ public function testArgumentsAreAddedToTheDefinition() { $command = new class () extends AbstractCommand { @@ -78,9 +72,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertTrue($command->getDefinition()->hasArgument('test')); } - /** - * @covers Joomla\Console\Command\AbstractCommand - */ public function testOptionsAreAddedToTheDefinition() { $command = new class () extends AbstractCommand { @@ -94,9 +85,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertTrue($command->getDefinition()->hasOption('test')); } - /** - * @covers Joomla\Console\Command\AbstractCommand - */ public function testTheDefaultCommandNameIsRetrieved() { $command = new class () extends AbstractCommand { @@ -111,9 +99,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertSame('test:command', $command::getDefaultName()); } - /** - * @covers Joomla\Console\Command\AbstractCommand - */ public function testTheCommandHelpIsProcessed() { $command = new class () extends AbstractCommand { @@ -134,9 +119,6 @@ public function getHelp(): string $this->assertStringNotContainsString('%command.full_name%', $command->getProcessedHelp(), 'getProcessedHelp() replaces %command.full_name%'); } - /** - * @covers Joomla\Console\Command\AbstractCommand - */ public function testTheCommandSynopsisIsProcessed() { $command = new class () extends AbstractCommand { @@ -154,10 +136,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertEquals('test:command [--foo] [--] []', $command->getSynopsis()); } - /** - * @covers Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Application - */ public function testTheApplicationInputDefinitionIsMergedWithTheCommand() { $command = new class () extends AbstractCommand { @@ -194,10 +172,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in ); } - /** - * @covers Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Application - */ public function testTheArgumentsOfTheApplicationInputDefinitionAreNotMergedWithTheCommandUntilInstructed() { $command = new class () extends AbstractCommand { @@ -230,10 +204,6 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->assertTrue($command->getDefinition()->hasArgument('foo')); } - /** - * @covers Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Application - */ public function testTheApplicationHelperSetIsMergedToTheCommand() { $command = new class () extends AbstractCommand { diff --git a/tests/Command/HelpCommandTest.php b/tests/Command/HelpCommandTest.php index 2695dba6..e1c28814 100644 --- a/tests/Command/HelpCommandTest.php +++ b/tests/Command/HelpCommandTest.php @@ -8,8 +8,13 @@ namespace Joomla\Console\Tests\Command; use Joomla\Console\Application; +use Joomla\Console\Command\AbstractCommand; use Joomla\Console\Command\HelpCommand; use Joomla\Console\Command\ListCommand; +use Joomla\Console\Descriptor\TextDescriptor; +use Joomla\Console\Helper\DescriptorHelper; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; @@ -17,16 +22,14 @@ /** * Test class for \Joomla\Console\Command\HelpCommand */ +#[CoversClass(HelpCommand::class)] +#[UsesClass(Application::class)] +#[UsesClass(AbstractCommand::class)] +#[UsesClass(ListCommand::class)] +#[UsesClass(TextDescriptor::class)] +#[UsesClass(DescriptorHelper::class)] class HelpCommandTest extends TestCase { - /** - * @covers Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testTheCommandIsExecutedWithACommandName() { $input = new ArrayInput( @@ -48,14 +51,6 @@ public function testTheCommandIsExecutedWithACommandName() $this->assertStringContainsString('list []', $screenOutput); } - /** - * @covers Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testTheCommandIsExecutedWithACommandClass() { $input = new ArrayInput( diff --git a/tests/Command/ListCommandTest.php b/tests/Command/ListCommandTest.php index 43c1f78a..4a40c766 100644 --- a/tests/Command/ListCommandTest.php +++ b/tests/Command/ListCommandTest.php @@ -8,8 +8,15 @@ namespace Joomla\Console\Tests\Command; use Joomla\Console\Application; +use Joomla\Console\Command\AbstractCommand; +use Joomla\Console\Command\HelpCommand; use Joomla\Console\Command\ListCommand; +use Joomla\Console\Descriptor\ApplicationDescription; +use Joomla\Console\Descriptor\TextDescriptor; +use Joomla\Console\Helper\DescriptorHelper; use Joomla\Console\Tests\Fixtures\Command\NamespacedCommand; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; @@ -17,17 +24,15 @@ /** * Test class for \Joomla\Console\Command\ListCommand */ +#[CoversClass(ListCommand::class)] +#[UsesClass(Application::class)] +#[UsesClass(AbstractCommand::class)] +#[UsesClass(HelpCommand::class)] +#[UsesClass(ApplicationDescription::class)] +#[UsesClass(TextDescriptor::class)] +#[UsesClass(DescriptorHelper::class)] class ListCommandTest extends TestCase { - /** - * @covers Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Descriptor\ApplicationDescription - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testTheCommandIsExecuted() { $input = new ArrayInput( @@ -53,15 +58,6 @@ public function testTheCommandIsExecuted() } } - /** - * @covers Joomla\Console\Command\ListCommand - * @uses Joomla\Console\Application - * @uses Joomla\Console\Command\AbstractCommand - * @uses Joomla\Console\Command\HelpCommand - * @uses Joomla\Console\Descriptor\ApplicationDescription - * @uses Joomla\Console\Descriptor\TextDescriptor - * @uses Joomla\Console\Helper\DescriptorHelper - */ public function testTheCommandIsExecutedForANamespace() { $input = new ArrayInput( diff --git a/tests/Loader/ContainerLoaderTest.php b/tests/Loader/ContainerLoaderTest.php index 656e7fed..ddca4e65 100644 --- a/tests/Loader/ContainerLoaderTest.php +++ b/tests/Loader/ContainerLoaderTest.php @@ -7,8 +7,11 @@ namespace Joomla\Console\Tests\Loader; +use Joomla\Console\Command\AbstractCommand; use Joomla\Console\Loader\ContainerLoader; use Joomla\Console\Tests\Fixtures\Command\NamespacedCommand; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; @@ -17,6 +20,8 @@ /** * Test class for \Joomla\Console\Loader\ContainerLoader */ +#[CoversClass(ContainerLoader::class)] +#[UsesClass(AbstractCommand::class)] class ContainerLoaderTest extends TestCase { /** @@ -35,10 +40,6 @@ protected function setUp(): void $this->container = $this->createMock(ContainerInterface::class); } - /** - * @covers Joomla\Console\Loader\ContainerLoader - * @uses Joomla\Console\Command\AbstractCommand - */ public function testTheLoaderRetrievesACommand() { $command = new NamespacedCommand(); @@ -62,9 +63,6 @@ public function testTheLoaderRetrievesACommand() ); } - /** - * @covers Joomla\Console\Loader\ContainerLoader - */ public function testTheLoaderDoesNotRetrieveAnUnknownCommand() { $this->expectException(CommandNotFoundException::class); @@ -83,9 +81,6 @@ public function testTheLoaderDoesNotRetrieveAnUnknownCommand() (new ContainerLoader($this->container, [$commandName => $serviceId]))->get($commandName); } - /** - * @covers Joomla\Console\Loader\ContainerLoader - */ public function testTheLoaderHasACommand() { $commandName = 'test:loader'; From abed6871f7f23b06b9404c3b1f8ae0848c6fa223 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:26:51 +0200 Subject: [PATCH 3/7] use testhelper from joomla/test for php reflection --- tests/ApplicationTest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/ApplicationTest.php b/tests/ApplicationTest.php index 84ecc5d6..dbac6481 100644 --- a/tests/ApplicationTest.php +++ b/tests/ApplicationTest.php @@ -237,10 +237,7 @@ public function testHasGetCommand() $this->assertSame($command, $this->object->getCommand('test:namespaced')); // Simulates passing the --help option - $r = new \ReflectionObject($this->object); - $p = $r->getProperty('wantsHelp'); - $p->setAccessible(true); - $p->setValue($this->object, true); + TestHelper::setValue($this->object, 'wantsHelp', true); /** @var HelpCommand $helpCommand */ $helpCommand = $this->object->getCommand('test:namespaced'); From 3f7e63642af2da37a8ae8e917b88953346afb89e Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:27:43 +0200 Subject: [PATCH 4/7] convert mock to stub if no expectations were configured --- tests/Command/AbstractCommandTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/Command/AbstractCommandTest.php b/tests/Command/AbstractCommandTest.php index 572f0e33..347684b7 100644 --- a/tests/Command/AbstractCommandTest.php +++ b/tests/Command/AbstractCommandTest.php @@ -34,8 +34,8 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in } }; - $input = $this->createMock(InputInterface::class); - $output = $this->createMock(OutputInterface::class); + $input = $this->createStub(InputInterface::class); + $output = $this->createStub(OutputInterface::class); $this->assertSame(0, $command->execute($input, $output)); } @@ -49,8 +49,8 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in } }; - $input = $this->createMock(InputInterface::class); - $output = $this->createMock(OutputInterface::class); + $input = $this->createStub(InputInterface::class); + $output = $this->createStub(OutputInterface::class); $application = new Application($input, $output); @@ -145,8 +145,8 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in } }; - $input = $this->createMock(InputInterface::class); - $output = $this->createMock(OutputInterface::class); + $input = $this->createStub(InputInterface::class); + $output = $this->createStub(OutputInterface::class); $application = new Application($input, $output); @@ -181,8 +181,8 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in } }; - $input = $this->createMock(InputInterface::class); - $output = $this->createMock(OutputInterface::class); + $input = $this->createStub(InputInterface::class); + $output = $this->createStub(OutputInterface::class); $application = new Application($input, $output); @@ -213,8 +213,8 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in } }; - $input = $this->createMock(InputInterface::class); - $output = $this->createMock(OutputInterface::class); + $input = $this->createStub(InputInterface::class); + $output = $this->createStub(OutputInterface::class); $application = new Application($input, $output); From 43075ad84cb78b904e9169acc769be5c6dd09ca7 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:28:31 +0200 Subject: [PATCH 5/7] update assert calls prefer same (typesafe) over equals --- tests/ApplicationTest.php | 10 +++++----- tests/Command/AbstractCommandTest.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/ApplicationTest.php b/tests/ApplicationTest.php index dbac6481..a7841d62 100644 --- a/tests/ApplicationTest.php +++ b/tests/ApplicationTest.php @@ -282,21 +282,21 @@ public function testGetNamespaces() $this->object->addCommand(new NamespacedCommand()); $this->object->addCommand(new AliasedCommand()); - $this->assertEquals(['test'], $this->object->getNamespaces()); + $this->assertSame(['test'], $this->object->getNamespaces()); } public function testFindNamespace() { $this->object->addCommand(new NamespacedCommand()); - $this->assertEquals('test', $this->object->findNamespace('test')); - $this->assertEquals( + $this->assertSame('test', $this->object->findNamespace('test')); + $this->assertSame( 'test', $this->object->findNamespace('t'), 'If an abbreviated namespace is given and is not ambiguous, the full namespace is returned' ); $this->object->addCommand(new AliasedCommand()); - $this->assertEquals('test', $this->object->findNamespace('test')); + $this->assertSame('test', $this->object->findNamespace('test')); } public function testFindAmbiguousNamespace() @@ -360,7 +360,7 @@ public function testHandlingThrowables() $this->fail('The Throwable from the application should have been caught'); } catch (\Throwable $exception) { $this->assertInstanceOf(CommandNotFoundException::class, $exception); - $this->assertEquals('The command "foo" does not exist.', $exception->getMessage()); + $this->assertSame('The command "foo" does not exist.', $exception->getMessage()); } } diff --git a/tests/Command/AbstractCommandTest.php b/tests/Command/AbstractCommandTest.php index 347684b7..ba96433d 100644 --- a/tests/Command/AbstractCommandTest.php +++ b/tests/Command/AbstractCommandTest.php @@ -133,7 +133,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $command->addOption('foo'); $command->addArgument('bar'); - $this->assertEquals('test:command [--foo] [--] []', $command->getSynopsis()); + $this->assertSame('test:command [--foo] [--] []', $command->getSynopsis()); } public function testTheApplicationInputDefinitionIsMergedWithTheCommand() @@ -165,7 +165,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $command->mergeApplicationDefinition(); - $this->assertEquals( + $this->assertSame( 3, $command->getDefinition()->getArgumentCount(), 'mergeApplicationDefinition() does not try to merge the application arguments and options multiple times' From e2301699125ba1fcd1c6b240dcfd9248d59d1b03 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:33:35 +0200 Subject: [PATCH 6/7] unnecessary check removed `assertMatchesRegularExpression` is always available --- tests/Command/ListCommandTest.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/Command/ListCommandTest.php b/tests/Command/ListCommandTest.php index 4a40c766..a14bd470 100644 --- a/tests/Command/ListCommandTest.php +++ b/tests/Command/ListCommandTest.php @@ -51,11 +51,7 @@ public function testTheCommandIsExecuted() $screenOutput = $output->fetch(); - if (method_exists($this, 'assertMatchesRegularExpression')) { - $this->assertMatchesRegularExpression('/help\s{2,}Show the help for a command/', $screenOutput); - } else { - $this->assertRegExp('/help\s{2,}Show the help for a command/', $screenOutput); - } + $this->assertMatchesRegularExpression('/help\s{2,}Show the help for a command/', $screenOutput); } public function testTheCommandIsExecutedForANamespace() @@ -81,10 +77,6 @@ public function testTheCommandIsExecutedForANamespace() $screenOutput = $output->fetch(); - if (method_exists($this, 'assertMatchesRegularExpression')) { - $this->assertMatchesRegularExpression('/test:namespaced\s{2,}A testing command/', $screenOutput); - } else { - $this->assertRegExp('/test:namespaced\s{2,}A testing command/', $screenOutput); - } + $this->assertMatchesRegularExpression('/test:namespaced\s{2,}A testing command/', $screenOutput); } } From 0e492ba4558060706904549957a7249be5308de4 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Mon, 10 Aug 2026 21:34:49 +0200 Subject: [PATCH 7/7] fix squizlabs/php_codesniffer security https://packagist.org/security-advisories/PKSA-rdkp-vv9z-mjkg --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 446eddc8..a6cc3c18 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "joomla/test": "^4.0", "phpunit/phpunit": "^12.0", "psr/container": "^2.0", - "squizlabs/php_codesniffer": "~3.10.2", + "squizlabs/php_codesniffer": "^3.10.2", "phpstan/phpstan": "2.1.17", "phpstan/phpstan-deprecation-rules": "2.0.3" },