Lines Matching refs:container
15 $container = new Container();
18 $container->set(MockService::class, function (Container $container) {
19 $service = new MockService($container->get(MockDependency::class));
25 $container->set(MockDependency::class, function (Container $container) {
30 $service = $container->get(MockService::class);
34 $dependency = $container->get(MockDependency::class);
46 $container = new Container();
48 $this->assertFalse($container->has(MockDependency::class));
50 $container->set(MockDependency::class, function (Container $container) {
54 $this->assertFalse($container->has(MockService::class));
55 $this->assertTrue($container->has(MockDependency::class));
60 $container = new Container();
64 $container->get('foo');
69 $container = new Container();
70 $container->set(\stdClass::class, '');
75 $container->get(\stdClass::class);
80 $container = new Container();
82 $container->set(MockService::class, function (Container $container) {
83 return new MockService($container->get(MockService::class));
86 $container->set(MockService::class, function (Container $container) {
87 return new MockService($container->get(MockService::class));
93 $container->get(MockService::class);
98 $container = new Container([
100 'baz' => function (Container $container) {
101 return $container->get('foo');
105 $this->assertTrue($container->has('foo'));
106 $this->assertTrue($container->has('baz'));
107 $this->assertEquals('bar', $container->get('foo'));
108 $this->assertEquals('bar', $container->get('baz'));