Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit fdd4a60

Browse files
michalbundyraweierophinney
authored andcommitted
Test that pulling invalid invokable by alias results in error
Conflicts: src/InvokableTestTrait.php
1 parent 255d814 commit fdd4a60

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/InvokableTestTrait.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Zend\ContainerConfigTest;
1111

12+
use ArgumentCountError;
1213
use Psr\Container\ContainerExceptionInterface;
1314
use Throwable;
1415
use TypeError;
@@ -109,4 +110,28 @@ public function testFetchingInvokableThatHasRequiredConstructorParametersResults
109110

110111
$this->assertTrue($caught, 'No TypeError or ContainerExceptionInterface thrown when one was expected');
111112
}
113+
114+
public function testFetchingInvalidInvokableServiceByAliasResultsInException()
115+
{
116+
$config = [
117+
'invokables' => [
118+
'alias' => TestAsset\FactoryWithRequiredParameters::class,
119+
],
120+
];
121+
122+
$container = $this->createContainer($config);
123+
124+
self::assertTrue($container->has('alias'));
125+
126+
$caught = false;
127+
try {
128+
$container->get('alias');
129+
} catch (Throwable $e) {
130+
if ($e instanceof ArgumentCountError || $e instanceof ContainerExceptionInterface) {
131+
$caught = true;
132+
}
133+
}
134+
135+
$this->assertTrue($caught, 'No ArgumentError or ContainerExceptionInterface thrown when one was expected');
136+
}
112137
}

0 commit comments

Comments
 (0)