@@ -30,12 +30,14 @@ public function testWillThrowExceptionIfClassNotFound(): void
3030 {
3131 $ container = $ this ->createMock (ContainerInterface::class);
3232
33+ $ subject = 'test ' ;
34+
3335 $ this ->expectException (RuntimeException::class);
3436 $ this ->expectExceptionMessage (
35- sprintf (RuntimeException::MESSAGE_CLASS_NOT_FOUND , ' test ' )
37+ sprintf (RuntimeException::MESSAGE_CLASS_NOT_FOUND , $ subject )
3638 );
3739
38- (new AttributedServiceFactory ())($ container , ' test ' );
40+ (new AttributedServiceFactory ())($ container , $ subject );
3941 }
4042
4143 /**
@@ -135,6 +137,31 @@ public function __construct(array $config = [])
135137 (new AttributedServiceFactory ())($ container , $ subject ::class);
136138 }
137139
140+ /**
141+ * @throws ContainerExceptionInterface
142+ * @throws Exception
143+ * @throws NotFoundExceptionInterface
144+ */
145+ public function testWillThrowExceptionIfDependencyNotFound (): void
146+ {
147+ $ container = $ this ->createMock (ContainerInterface::class);
148+
149+ $ subject = new class
150+ {
151+ #[Inject('test ' )]
152+ public function __construct (mixed $ test = null )
153+ {
154+ }
155+ };
156+
157+ $ this ->expectException (RuntimeException::class);
158+ $ this ->expectExceptionMessage (
159+ sprintf (RuntimeException::MESSAGE_CLASS_NOT_FOUND , 'test ' )
160+ );
161+
162+ (new AttributedServiceFactory ())($ container , $ subject ::class);
163+ }
164+
138165 /**
139166 * @throws ContainerExceptionInterface
140167 * @throws Exception
0 commit comments