Skip to content

Commit 43adf10

Browse files
committed
cover missing lines
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent d4c6833 commit 43adf10

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

test/Factory/AttributedServiceFactoryTest.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)