diff --git a/src/Provide/Router/RouterCollectionProvider.php b/src/Provide/Router/RouterCollectionProvider.php index dd74dc9b..56ae906e 100644 --- a/src/Provide/Router/RouterCollectionProvider.php +++ b/src/Provide/Router/RouterCollectionProvider.php @@ -5,16 +5,14 @@ namespace BEAR\Package\Provide\Router; use BEAR\Sunday\Extension\Router\RouterInterface; -use Ray\Di\Di\Inject; use Ray\Di\Di\Named; use Ray\Di\ProviderInterface; /** @implements ProviderInterface */ class RouterCollectionProvider implements ProviderInterface { - #[Inject] public function __construct( - #[Named('router')] private RouterInterface $primaryRouter, + #[Named('primary_router')] private RouterInterface $primaryRouter, private WebRouterInterface $webRouter, ) { } diff --git a/tests/Fake/fake-app/src/Module/AppModule.php b/tests/Fake/fake-app/src/Module/AppModule.php index 1c50813c..cd833711 100644 --- a/tests/Fake/fake-app/src/Module/AppModule.php +++ b/tests/Fake/fake-app/src/Module/AppModule.php @@ -33,6 +33,7 @@ protected function configure() [NullInterceptor::class] ); $this->bind(FakeFoo::class); + $this->bind(FakeDep::class); $this->bind(Auth::class)->toProvider(AuthProvider::class); } } diff --git a/tests/Provide/Router/RouterCollectionProviderTest.php b/tests/Provide/Router/RouterCollectionProviderTest.php new file mode 100644 index 00000000..672f1ffd --- /dev/null +++ b/tests/Provide/Router/RouterCollectionProviderTest.php @@ -0,0 +1,33 @@ +install(new PackageModule()); + $this->bind(RouterInterface::class)->annotatedWith('primary_router')->toInstance(new FakeWebRouter('page://self', new HttpMethodParams())); + $this->bind(WebRouterInterface::class)->to(WebRouter::class); + $this->bind(RouterInterface::class)->toProvider(RouterCollectionProvider::class); + } + }; + $i = new Injector(); + $injector = new Injector($module); + $router = $injector->getInstance(RouterInterface::class); + $this->assertInstanceOf(RouterInterface::class, $router); + } +}