This repository was archived by the owner on Jan 21, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 10
10
namespace Zend \ContainerConfigTest ;
11
11
12
12
use ArgumentCountError ;
13
+ use Error ;
13
14
use Psr \Container \ContainerExceptionInterface ;
14
15
use Zend \ContainerConfigTest \Helper \Assert ;
15
16
@@ -125,4 +126,44 @@ function () use ($container) {
125
126
[ArgumentCountError::class, ContainerExceptionInterface::class]
126
127
);
127
128
}
129
+
130
+ final public function testFetchingNonExistingInvokableServiceResultsInException () : void
131
+ {
132
+ $ config = [
133
+ 'invokables ' => [
134
+ TestAsset \NonExistent::class,
135
+ ],
136
+ ];
137
+
138
+ $ container = $ this ->createContainer ($ config );
139
+
140
+ self ::assertTrue ($ container ->has (TestAsset \NonExistent::class));
141
+
142
+ Assert::expectedExceptions (
143
+ function () use ($ container ) {
144
+ $ container ->get (TestAsset \NonExistent::class);
145
+ },
146
+ [Error::class, ContainerExceptionInterface::class]
147
+ );
148
+ }
149
+
150
+ final public function testFetchingNonExistingInvokableByAliasServiceResultsInException () : void
151
+ {
152
+ $ config = [
153
+ 'invokables ' => [
154
+ 'alias ' => TestAsset \NonExistent::class,
155
+ ],
156
+ ];
157
+
158
+ $ container = $ this ->createContainer ($ config );
159
+
160
+ self ::assertTrue ($ container ->has ('alias ' ));
161
+
162
+ Assert::expectedExceptions (
163
+ function () use ($ container ) {
164
+ $ container ->get ('alias ' );
165
+ },
166
+ [Error::class, ContainerExceptionInterface::class]
167
+ );
168
+ }
128
169
}
You can’t perform that action at this time.
0 commit comments