public function testGetAnnotationsFromPropertyOrClassFallback() { $var_annotation = new VarAnnotation(); $var_annotation->type = 'DT'; $expected = 'OK'; $this->annotationManager->shouldReceive('getPropertyAnnotations')->with($this->property, null, '@var')->once()->andReturn(array($var_annotation)); $this->annotationManager->shouldReceive('getPropertyAnnotations')->with($this->property, null, 'A')->once()->andReturn(array()); $this->annotationManager->shouldReceive('getClassAnnotations')->with('DT', 'A')->once()->andReturn('OK'); $this->assertEquals($expected, $this->property->getAnnotationsFromPropertyOrClass('A')); }
/** * Returns final selector to be used for element locating. * * @return array * @throws AnnotationException When required @find-by annotation is missing. */ protected function getSelector() { /* @var $annotations FindByAnnotation[] */ $annotations = $this->property->getAnnotationsFromPropertyOrClass('@find-by'); $selector = $annotations ? $annotations[0]->getSelector() : array(); if (!$selector) { $parameters = array((string) $this->property, $this->property->getDataType()); $message = '@find-by must be specified in the property "%s" DocBlock or in class "%s" DocBlock'; throw new AnnotationException(vsprintf($message, $parameters), AnnotationException::TYPE_REQUIRED); } return $selector; }
/** * Returns name of the element. * * @param Property $property Property, to inspect. * * @return string */ protected function getElementName(Property $property) { /* @var $annotations ElementNameAnnotation[] */ $annotations = $property->getAnnotationsFromPropertyOrClass('@element-name'); return $annotations ? $annotations[0]->name : (string) $property; }