19 declare(strict_types=1);
39 $result = $this->resolver->resolveDependencies([]);
41 $this->assertEquals([], $result);
46 $component = $this->createMock(Component::class);
48 $name = TestInterface::class;
50 $pull =
new D\In(
D\InType::PULL, $name);
51 $provide =
new D\Out(
D\OutType::PROVIDE, $name,
null, []);
53 $c1 =
new D\OfComponent($component, $pull);
54 $c2 =
new D\OfComponent($component, $provide);
56 $result = $this->resolver->resolveDependencies([], $c1, $c2);
58 $pull =
new D\In(
D\InType::PULL, $name);
59 $provide =
new D\Out(
D\OutType::PROVIDE, $name,
null, []);
60 $pull->addResolution($provide);
62 $c1 =
new D\OfComponent($component, $pull);
63 $c2 =
new D\OfComponent($component, $provide);
65 $this->assertEquals([$c1, $c2], $result);
70 $this->expectException(\LogicException::class);
72 $component = $this->createMock(Component::class);
74 $name = TestInterface::class;
76 $pull =
new D\In(
D\InType::PULL, $name);
78 $c1 =
new D\OfComponent($component, $pull);
80 $this->resolver->resolveDependencies([], $c1);
85 $this->expectException(\LogicException::class);
87 $component = $this->createMock(Component::class);
89 $name = TestInterface::class;
91 $pull =
new D\In(
D\InType::PULL, $name);
92 $provide1 =
new D\Out(
D\OutType::PROVIDE, $name,
null, []);
93 $provide2 =
new D\Out(
D\OutType::PROVIDE, $name,
null, []);
95 $c1 =
new D\OfComponent($component, $pull);
96 $c2 =
new D\OfComponent($component, $provide1);
97 $c3 =
new D\OfComponent($component, $provide2);
99 $this->resolver->resolveDependencies([], $c1, $c2, $c3);
104 $component = $this->createMock(Component::class);
106 $name = TestInterface::class;
108 $seek =
new D\In(
D\InType::SEEK, $name);
110 $c1 =
new D\OfComponent($component, $seek);
112 $result = $this->resolver->resolveDependencies([], $c1);
114 $this->assertEquals([$c1], $result);
119 $component = $this->createMock(Component::class);
121 $name = TestInterface::class;
123 $seek =
new D\In(
D\InType::SEEK, $name);
124 $contribute1 =
new D\Out(
D\OutType::CONTRIBUTE, $name,
null, []);
125 $contribute2 =
new D\Out(
D\OutType::CONTRIBUTE, $name,
null, []);
127 $c1 =
new D\OfComponent($component, $seek);
128 $c2 =
new D\OfComponent($component, $contribute1);
129 $c3 =
new D\OfComponent($component, $contribute2);
131 $result = $this->resolver->resolveDependencies([], $c1, $c2, $c3);
134 $seek =
new D\In(
D\InType::SEEK, $name);
135 $contribute1 =
new D\Out(
D\OutType::CONTRIBUTE, $name,
null, []);
136 $contribute2 =
new D\Out(
D\OutType::CONTRIBUTE, $name,
null, []);
137 $seek->addResolution($contribute1);
138 $seek->addResolution($contribute2);
140 $c1 =
new D\OfComponent($component, $seek);
141 $c2 =
new D\OfComponent($component, $contribute1);
142 $c3 =
new D\OfComponent($component, $contribute2);
144 $this->assertEquals([$c1, $c2, $c3], $result);
149 $component = $this->createMock(Component::class);
151 $name = TestInterface::class;
153 $use =
new D\In(
D\InType::USE, $name);
154 $implement =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
156 $c1 =
new D\OfComponent($component, $use);
157 $c2 =
new D\OfComponent($component, $implement);
159 $result = $this->resolver->resolveDependencies([], $c1, $c2);
161 $use =
new D\In(
D\InType::USE, $name);
162 $implement =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
163 $use->addResolution($implement);
165 $c1 =
new D\OfComponent($component, $use);
166 $c2 =
new D\OfComponent($component, $implement);
168 $this->assertEquals([$c1, $c2], $result);
173 $this->expectException(\LogicException::class);
175 $component = $this->createMock(Component::class);
177 $name = TestInterface::class;
179 $use =
new D\In(
D\InType::USE, $name);
181 $c1 =
new D\OfComponent($component, $use);
183 $this->resolver->resolveDependencies([], $c1);
188 $this->expectException(\LogicException::class);
190 $component = $this->createMock(Component::class);
192 $name = TestInterface::class;
194 $use =
new D\In(
D\InType::USE, $name);
195 $implement1 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
196 $implement2 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
198 $c1 =
new D\OfComponent($component, $use);
199 $c2 =
new D\OfComponent($component, $implement1);
200 $c3 =
new D\OfComponent($component, $implement2);
202 $this->resolver->resolveDependencies([], $c1, $c2, $c3);
207 $component = $this->createMock(Component::class);
209 $name = TestInterface::class;
211 $use =
new D\In(
D\InType::USE, $name);
212 $implement1 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
213 $implement2 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\OtherClass"], []);
215 $c1 =
new D\OfComponent($component, $use);
216 $c2 =
new D\OfComponent($component, $implement1);
217 $c3 =
new D\OfComponent($component, $implement2);
220 get_class($component) => [
221 TestInterface::class =>
"Some\\OtherClass" 225 $result = $this->resolver->resolveDependencies($disambiguation, $c1, $c2, $c3);
227 $use =
new D\In(
D\InType::USE, $name);
228 $implement1 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
229 $implement2 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\OtherClass"], []);
230 $use->addResolution($implement2);
232 $c1 =
new D\OfComponent($component, $use);
233 $c2 =
new D\OfComponent($component, $implement1);
234 $c3 =
new D\OfComponent($component, $implement2);
236 $this->assertEquals([$c1, $c2, $c3], $result);
241 $component = $this->createMock(Component::class);
243 $name = TestInterface::class;
245 $use =
new D\In(
D\InType::USE, $name);
246 $implement1 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
247 $implement2 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\OtherClass"], []);
249 $c1 =
new D\OfComponent($component, $use);
250 $c2 =
new D\OfComponent($component, $implement1);
251 $c3 =
new D\OfComponent($component, $implement2);
255 TestInterface::class =>
"Some\\OtherClass" 259 $result = $this->resolver->resolveDependencies($disambiguation, $c1, $c2, $c3);
261 $use =
new D\In(
D\InType::USE, $name);
262 $implement1 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\Class"], []);
263 $implement2 =
new D\Out(
D\OutType::IMPLEMENT, $name, [
"class" =>
"Some\\OtherClass"], []);
264 $use->addResolution($implement2);
267 $c1 =
new D\OfComponent($component, $use);
268 $c2 =
new D\OfComponent($component, $implement1);
269 $c3 =
new D\OfComponent($component, $implement2);
271 $this->assertEquals([$c1, $c2, $c3], $result);
276 $this->expectException(\LogicException::class);
278 $component = $this->createMock(Component::class);
280 $name = TestInterface::class;
281 $name2 = TestInterface2::class;
283 $pull =
new D\In(
D\InType::PULL, $name);
284 $provide =
new D\Out(
D\OutType::PROVIDE, $name2,
"Some\\Class", [$pull], []);
285 $c1 =
new D\OfComponent($component, $pull, $provide);
287 $pull =
new D\In(
D\InType::PULL, $name2);
288 $provide =
new D\Out(
D\OutType::PROVIDE, $name,
"Some\\OtherClass", [$pull], []);
289 $c2 =
new D\OfComponent($component, $pull, $provide);
292 $result = $this->resolver->resolveDependencies([], $c1, $c2);
297 $this->expectException(\LogicException::class);
299 $component = $this->createMock(Component::class);
301 $name = TestInterface::class;
302 $name2 = TestInterface2::class;
303 $name3 = TestInterface3::class;
305 $pull =
new D\In(
D\InType::PULL, $name);
306 $provide =
new D\Out(
D\OutType::PROVIDE, $name2,
"Some\\Class", [$pull], []);
307 $c1 =
new D\OfComponent($component, $pull, $provide);
309 $pull =
new D\In(
D\InType::PULL, $name2);
310 $provide =
new D\Out(
D\OutType::PROVIDE, $name3,
"Some\\OtherClass", [$pull], []);
311 $c2 =
new D\OfComponent($component, $pull, $provide);
313 $pull =
new D\In(
D\InType::PULL, $name3);
314 $provide =
new D\Out(
D\OutType::PROVIDE, $name,
"Some\\OtherOtherClass", [$pull], []);
315 $c3 =
new D\OfComponent($component, $pull, $provide);
318 $result = $this->resolver->resolveDependencies([], $c1, $c2, $c3);
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
testResolveUseOneOption()
testUseFailsNotExistent()
testUseDisambiguateDuplicateSpecific()
testPullFailsNotExistent()
testUseDisambiguateDuplicateGeneric()