/**
  * @return WebElementProxy
  * @dataProvider proxyDataProvider
  */
 public function testProxyWebElement($element_class, $proxy_class)
 {
     $search_context = m::mock('\\QATools\\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, $element_class);
     $this->assertEquals($node_element->getXpath(), $proxy->getXpath());
     return $proxy;
 }
 /**
  * @return WebElementProxy
  * @dataProvider proxyDataProvider
  */
 public function testProxyWebElement($element_class, $proxy_class)
 {
     $search_context = m::mock('\\QATools\\QATools\\PageObject\\ISearchContext');
     $this->locator->shouldReceive('getSearchContext')->andReturn($search_context);
     $node_elements = array($this->createNodeElement('xpath1'), $this->createNodeElement('xpath2'));
     $this->locator->shouldReceive('findAll')->andReturn($node_elements);
     $this->property->shouldReceive('isSimpleDataType')->andReturn(false);
     $this->property->shouldReceive('getDataType')->andReturn($element_class);
     $proxy = $this->decorator->decorate($this->property);
     $this->assertProxy($proxy, $proxy_class, $element_class);
     if (strpos($proxy_class, 'Collection') !== false) {
         foreach ($proxy->getObject() as $index => $proxied_element) {
             $this->assertEquals($node_elements[$index]->getXpath(), $proxied_element->getXpath(), 'The method call is proxied to collection element.');
         }
     } else {
         $this->assertEquals($node_elements[0]->getXpath(), $proxy->getXpath(), 'The method call is proxied.');
     }
     return $proxy;
 }
Beispiel #3
0
 /**
  * Initializes fields within given search context.
  *
  * @param ISearchContext     $search_context     Search context.
  * @param IPropertyDecorator $property_decorator Property decorator.
  *
  * @return self
  */
 protected function proxyFields(ISearchContext $search_context, IPropertyDecorator $property_decorator)
 {
     foreach ($this->getProperties($search_context) as $property) {
         $proxy = $property_decorator->decorate($property);
         if ($proxy !== null) {
             $property->setAccessible(true);
             $property->setValue($search_context, $proxy);
         }
     }
     return $this;
 }