/** * @test * it should allow a deferred service provider to bind and singleton classes */ public function it_should_allow_a_deferred_service_provider_to_bind_and_singleton_classes() { $container = new tad_DI52_Container(); $container->register('DeferredServiceProviderThree'); $instance1 = $container->resolve('TestInterfaceOne'); $instance2 = $container->resolve('TestInterfaceOne'); $this->assertSame($instance1, $instance2); $instance3 = $container->resolve('TestInterfaceTwo'); $instance4 = $container->resolve('TestInterfaceTwo'); $this->assertEquals($instance3, $instance4); $this->assertNotSame($instance3, $instance4); }
/** * @test * it should return the var value when directly requested */ public function it_should_return_the_var_value_when_directly_requested() { $container = new tad_DI52_Container(); $container['some-var'] = 23; $value = $container->resolve('%some-var%'); $this->assertEquals(23, $value); }
protected function resolveValue($value) { return $this->container->resolve($value); }