File tree Expand file tree Collapse file tree
src/bundle/Core/DependencyInjection/Compiler
tests/bundle/Core/DependencyInjection/Compiler Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99namespace Ibexa \Bundle \Core \DependencyInjection \Compiler ;
1010
11+ use Symfony \Component \Console \Command \Command ;
1112use Symfony \Component \Console \Input \InputOption ;
1213use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
1314use Symfony \Component \DependencyInjection \ContainerBuilder ;
@@ -19,6 +20,11 @@ public function process(ContainerBuilder $container): void
1920 foreach ($ container ->findTaggedServiceIds ('console.command ' ) as $ id => $ attributes ) {
2021 $ definition = $ container ->getDefinition ($ id );
2122
23+ $ class = $ definition ->getClass ();
24+ if ($ class === null || !is_a ($ class , Command::class, true )) {
25+ continue ;
26+ }
27+
2228 $ definition ->addMethodCall ('addOption ' , [
2329 'siteaccess ' ,
2430 null ,
Original file line number Diff line number Diff line change 1010
1111use Ibexa \Bundle \Core \DependencyInjection \Compiler \ConsoleCommandPass ;
1212use Matthias \SymfonyDependencyInjectionTest \PhpUnit \AbstractCompilerPassTestCase ;
13+ use Symfony \Component \Console \Command \Command ;
1314use Symfony \Component \Console \Input \InputOption ;
1415use Symfony \Component \DependencyInjection \ContainerBuilder ;
1516use Symfony \Component \DependencyInjection \Definition ;
@@ -23,7 +24,7 @@ protected function registerCompilerPass(ContainerBuilder $container): void
2324
2425 public function testAddSiteaccessOption (): void
2526 {
26- $ commandDefinition = new Definition ();
27+ $ commandDefinition = new Definition (Command::class );
2728 $ serviceId = 'some_service_id ' ;
2829 $ commandDefinition ->addTag ('console.command ' );
2930
@@ -41,4 +42,16 @@ public function testAddSiteaccessOption(): void
4142 ]
4243 );
4344 }
45+
46+ public function testSkipsSiteaccessOptionOnInvokables (): void
47+ {
48+ $ commandDefinition = new Definition ();
49+ $ serviceId = 'some_service_id ' ;
50+ $ commandDefinition ->addTag ('console.command ' );
51+
52+ $ this ->setDefinition ($ serviceId , $ commandDefinition );
53+ $ this ->compile ();
54+
55+ $ this ->assertContainerBuilderHasService ($ serviceId );
56+ }
4457}
You can’t perform that action at this time.
0 commit comments