/**
  * It's actually the main test.
  */
 public function test_if_same_instance_is_returned()
 {
     $this->setUpRegisterSelectors();
     $selector1 = $this->selectorProvider->get('ul li');
     $selector2 = $this->selectorProvider->get('ul li');
     $selector3 = $this->selectorProvider->get('a');
     $this->assertSame($selector1, $selector2);
     $this->assertNotSame($selector1, $selector3);
     $this->assertTrue($selector1 instanceof SelectorInterface);
     $this->assertTrue($selector3 instanceof SelectorInterface);
     $selector4 = $this->selectorProvider->get('ul li', 'css-other');
     $this->assertNotSame($selector1, $selector4);
     //not same cause from different selectors
     $this->assertTrue($selector4 instanceof SelectorInterface);
 }
Example #2
0
 /**
  * @param string $method Registered extract method
  * @param string $selectorText Selector string
  * @param string $selectorType
  * @param array $params
  * @return ExtractionMethod
  */
 public function get($method, $selectorText = '', $selectorType = null, $params = [])
 {
     $class = $this->registeredMethods[$method];
     $selector = $this->selectorProvider->get($selectorText, $selectorType);
     return new $class($selector, $params);
 }