1515use Interop \Queue \Queue as InteropQueue ;
1616use PHPUnit \Framework \TestCase ;
1717use Psr \Container \ContainerInterface ;
18+ use Symfony \Component \Console \Attribute \AsCommand ;
1819use Symfony \Component \Console \Command \Command ;
1920use Symfony \Component \Console \Tester \CommandTester ;
2021
@@ -37,11 +38,22 @@ public function testCouldBeConstructedWithRequiredAttributes()
3738 new ConfigurableConsumeCommand ($ this ->createMock (ContainerInterface::class), 'default ' );
3839 }
3940
40- public function testShouldHaveCommandName ()
41+ public function testShouldHaveAsCommandAttributeWithCommandName ()
4142 {
42- $ command = new ConfigurableConsumeCommand ($ this ->createMock (ContainerInterface::class), 'default ' );
43+ $ commandClass = ConfigurableConsumeCommand::class;
44+
45+ $ reflectionClass = new \ReflectionClass ($ commandClass );
46+
47+ $ attributes = $ reflectionClass ->getAttributes (AsCommand::class);
48+
49+ $ this ->assertNotEmpty ($ attributes , 'The command does not have the AsCommand attribute. ' );
50+
51+ // Get the first attribute instance (assuming there is only one AsCommand attribute)
52+ $ asCommandAttribute = $ attributes [0 ];
4353
44- $ this ->assertEquals ('enqueue:transport:consume ' , $ command ->getName ());
54+ // Verify the 'name' parameter value
55+ $ attributeInstance = $ asCommandAttribute ->newInstance ();
56+ $ this ->assertEquals ('enqueue:transport:consume ' , $ attributeInstance ->name , 'The command name is not set correctly in the AsCommand attribute. ' );
4557 }
4658
4759 public function testShouldHaveExpectedOptions ()
@@ -192,7 +204,7 @@ public function testShouldExecuteConsumptionWithSeveralCustomQueues()
192204
193205 public function testShouldExecuteConsumptionWhenProcessorImplementsQueueSubscriberInterface ()
194206 {
195- $ processor = new class () implements Processor, QueueSubscriberInterface {
207+ $ processor = new class implements Processor, QueueSubscriberInterface {
196208 public function process (InteropMessage $ message , Context $ context )
197209 {
198210 }
0 commit comments