/** * Test that initization with the fromReflectionProperty() method * and an empty annotation works as expected. * * @return void */ public function testFromReflectionPropertyAndAnnotationWithSomeAttributes() { // prepare the annotation values $values = array('description' => 'A Description', 'beanInterface' => 'DummyEnterpriseBeanLocal', 'beanName' => 'DummyEnterpriseBean', 'lookup' => 'php:global/example/DummyEnterpriseBean'); // create a mock annotation implementation $beanAnnotation = $this->getMockBuilder('AppserverIo\\Psr\\EnterpriseBeans\\Annotations\\EnterpriseBean')->setConstructorArgs(array('EnterpriseBean', $values))->getMockForAbstractClass(); // create a mock annotation $annotation = $this->getMockBuilder('AppserverIo\\Lang\\Reflection\\ReflectionAnnotation')->setMethods(array('getAnnotationName', 'getValues', 'newInstance'))->setConstructorArgs(array('EnterpriseBean', $values))->getMock(); // mock the ReflectionAnnotation methods $annotation->expects($this->once())->method('getAnnotationName')->will($this->returnValue('EnterpriseBean')); $annotation->expects($this->once())->method('getValues')->will($this->returnValue($values)); $annotation->expects($this->once())->method('newInstance')->will($this->returnValue($beanAnnotation)); // initialize the annotation aliases $aliases = array(EnterpriseBean::ANNOTATION => EnterpriseBean::__getClass()); // initialize the reflection property $reflectionProperty = $this->getMockBuilder('AppserverIo\\Lang\\Reflection\\ReflectionProperty')->setConstructorArgs(array(__CLASS__, array(), $aliases))->setMethods(array('hasAnnotation', 'getAnnotation', 'getClassName', 'getPropertyName'))->getMock(); // mock the methods $reflectionProperty->expects($this->once())->method('hasAnnotation')->with(EnterpriseBean::ANNOTATION)->will($this->returnValue(true)); $reflectionProperty->expects($this->once())->method('getAnnotation')->with(EnterpriseBean::ANNOTATION)->will($this->returnValue($annotation)); $reflectionProperty->expects($this->exactly(1))->method('getClassName')->will($this->returnValue(__CLASS__)); $reflectionProperty->expects($this->exactly(2))->method('getPropertyName')->will($this->returnValue('dummyEnterpriseBean')); // initialize the descriptor from the reflection property $this->descriptor->fromReflectionProperty($reflectionProperty); // check that the descriptor has been initialized successfully $this->assertSame('env/DummyEnterpriseBean', $this->descriptor->getName()); $this->assertSame('DummyEnterpriseBeanLocal', $this->descriptor->getBeanInterface()); $this->assertSame('DummyEnterpriseBean', $this->descriptor->getBeanName()); $this->assertSame('A Description', $this->descriptor->getDescription()); $this->assertSame('php:global/example/DummyEnterpriseBean', $this->descriptor->getLookup()); }