public function testInjector() { $context = $this->getContext(); $injector = new \picon\Injector($context); foreach ($context->getResources() as $resource) { $injector->inject($resource); } $this->assertInstanceOf('TestService', $context->getResource("testRepository")->getTestService()); $this->assertInstanceOf('TestRepositoryName', $context->getResource("testRepository")->getTestRepo()); $this->assertInstanceOf('TestServiceName', $context->getResource("testRepository")->getTestServ()); $this->assertInstanceOf('TestRepository', $context->getResource("testService")->getTestRepository()); $this->assertInstanceOf('TestRepositoryName', $context->getResource("testService")->getTestRepo()); $this->assertInstanceOf('TestServiceName', $context->getResource("testService")->getTestServ()); $this->assertInstanceOf('TestRepository', $context->getResource("repo")->getTestRepository()); $this->assertInstanceOf('TestService', $context->getResource("repo")->getTestService()); $this->assertInstanceOf('TestServiceName', $context->getResource("repo")->getTestServ()); $this->assertInstanceOf('TestRepository', $context->getResource("serv")->getTestRepository()); $this->assertInstanceOf('TestService', $context->getResource("serv")->getTestService()); $this->assertInstanceOf('TestRepositoryName', $context->getResource("serv")->getTestRepo()); }
public function testWakeupInjection() { $context = $this->getContext(); $injector = new \picon\Injector($context); $object = new \InjectOnWakeupObject(); $injector->inject($object); $deserialized = $this->doSerialize($object); $this->assertSame($context->getResource("testService"), $object->getTestResource()); $this->assertSame($context->getResource("testService"), $deserialized->getTestResource()); }