/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ protected function setUp() { $instance = new ReflectionProperty(BeanFactory::class, 'instance'); $instance->setAccessible(true); $instance->setValue(null); BeanFactory::setAutoLoadSupport(true); $this->property = new ReflectionProperty(CollectionFixture::class, 'arrayObject'); }
/** * @test * @ignore * @expectedException PhSpring\Service\NoSuchBeanDefinitionException */ public function getMultiple() { BeanFactory::setAutoLoadSupport(true); $this->factory->addBeanClass(FirstImplementationOfInterface::class); $this->factory->addBeanClass(SecondImplementationOfInterface::class); $service10 = $this->factory->getBean(FirstImplementationOfInterface::class); $this->assertNotNull($service10); $this->assertInstanceOf(FirstImplementationOfInterface::class, $service10); $service11 = $this->factory->getBean('first'); $this->assertNotNull($service11); $this->assertInstanceOf(FirstImplementationOfInterface::class, $service11); $service20 = $this->factory->getBean(SecondImplementationOfInterface::class); $this->assertNotNull($service20); $this->assertInstanceOf(SecondImplementationOfInterface::class, $service20); $service21 = $this->factory->getBean(SecondImplementationOfInterface::class); $this->assertNotNull($service21); $this->assertInstanceOf(SecondImplementationOfInterface::class, $service21); $this->assertTrue($service10 !== $service20); $this->assertTrue($service10 === $service11); $this->assertTrue($service11 !== $service21); $this->assertTrue($service20 === $service21); $this->factory->getBean(ComponentInterface::class); }