コード例 #1
0
 /**
  * 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');
     if ($annotations && $annotations[0] instanceof ElementNameAnnotation) {
         return $annotations[0]->name;
     }
     return (string) $property;
 }
コード例 #2
0
ファイル: PropertyTest.php プロジェクト: qa-tools/qa-tools
 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'));
 }
コード例 #3
0
 /**
  * Returns final selectors to be used for element locating.
  *
  * @return array
  */
 protected function getSelectors()
 {
     /* @var $annotations FindByAnnotation[] */
     $annotations = $this->property->getAnnotationsFromPropertyOrClass('@find-by');
     $this->assertAnnotationClass($annotations);
     $selectors = array();
     foreach ($annotations as $annotation) {
         $selectors[] = $annotation->getSelector();
     }
     return $selectors;
 }