Пример #1
0
 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;
 }
 /**
  * @return WebElementProxy
  * @dataProvider proxyDataProvider
  */
 public function testProxyWebElement($element_class, $proxy_class)
 {
     $search_context = m::mock('\\aik099\\QATools\\PageObject\\ISearchContext');
     $this->locator->shouldReceive('getSearchContext')->andReturn($search_context);
     $node_element = $this->createNodeElement();
     $this->locator->shouldReceive('findAll')->andReturn(array($node_element));
     $this->property->shouldReceive('isSimpleDataType')->andReturn(false);
     $this->property->shouldReceive('getDataType')->andReturn($element_class);
     $proxy = $this->decorator->decorate($this->property);
     $this->assertProxy($proxy, $proxy_class, $search_context, $element_class);
     $this->assertEquals($node_element->getXpath(), $proxy->getXpath());
     return $proxy;
 }
 /**
  * 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;
 }
 /**
  * Returns proxy class, that can be used alongside with element class of a property.
  *
  * @param Property $property Property.
  *
  * @return string
  */
 protected function getProxyClass(Property $property)
 {
     $data_type = $property->getDataType();
     foreach ($this->elementToProxyMapping as $element_class => $proxy_class) {
         if ($this->classMatches($data_type, $element_class)) {
             return $proxy_class;
         }
     }
     return false;
 }
 /**
  * Checks, that given class is BEM Element or it's descendant.
  *
  * @param Property $property Property.
  *
  * @return boolean
  */
 private function _isBEMElement(Property $property)
 {
     return $this->classMatches($property->getDataType(), $this->_elementInterface);
 }