Skip to content

Commit

Permalink
Merge pull request #220 from aik099/remove-annotation-manager-from-lo…
Browse files Browse the repository at this point in the history
…cator

Remove "AnnotationManager" from the "DefaultElementLocator"
  • Loading branch information
aik099 committed Mar 17, 2024
2 parents ac35cb0 + ac56ca4 commit 28a2b0d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 48 deletions.
11 changes: 4 additions & 7 deletions library/QATools/QATools/BEM/ElementLocator/BEMElementLocator.php
Expand Up @@ -11,7 +11,6 @@
namespace QATools\QATools\BEM\ElementLocator;


use mindplay\annotations\AnnotationManager;
use QATools\QATools\BEM\Annotation\BEMAnnotation;
use QATools\QATools\BEM\Element\IBlock;
use QATools\QATools\PageObject\ElementLocator\DefaultElementLocator;
Expand All @@ -37,18 +36,16 @@ class BEMElementLocator extends DefaultElementLocator
/**
* Creates a new element locator.
*
* @param Property $property Property.
* @param ISearchContext $search_context The context to use when finding the element.
* @param AnnotationManager $annotation_manager Annotation manager.
* @param LocatorHelper $locator_helper Locator helper.
* @param Property $property Property.
* @param ISearchContext $search_context The context to use when finding the element.
* @param LocatorHelper $locator_helper Locator helper.
*/
public function __construct(
Property $property,
ISearchContext $search_context,
AnnotationManager $annotation_manager,
LocatorHelper $locator_helper
) {
parent::__construct($property, $search_context, $annotation_manager);
parent::__construct($property, $search_context);

$this->_helper = $locator_helper;
}
Expand Down
Expand Up @@ -57,7 +57,7 @@ public function __construct(
*/
public function createLocator(Property $property)
{
return new BEMElementLocator($property, $this->searchContext, $this->annotationManager, $this->_locatorHelper);
return new BEMElementLocator($property, $this->searchContext, $this->_locatorHelper);
}

}
Expand Up @@ -12,7 +12,6 @@


use Behat\Mink\Element\NodeElement;
use mindplay\annotations\AnnotationManager;
use QATools\QATools\PageObject\Annotation\FindByAnnotation;
use QATools\QATools\PageObject\Exception\AnnotationException;
use QATools\QATools\PageObject\Exception\ElementException;
Expand All @@ -34,13 +33,6 @@ class DefaultElementLocator implements IElementLocator
*/
protected $searchContext;

/**
* Annotation manager.
*
* @var AnnotationManager
*/
protected $annotationManager;

/**
* Property.
*
Expand All @@ -51,18 +43,13 @@ class DefaultElementLocator implements IElementLocator
/**
* Creates a new element locator.
*
* @param Property $property Property.
* @param ISearchContext $search_context The context to use when finding the element.
* @param AnnotationManager $annotation_manager Annotation manager.
* @param Property $property Property.
* @param ISearchContext $search_context The context to use when finding the element.
*/
public function __construct(
Property $property,
ISearchContext $search_context,
AnnotationManager $annotation_manager
) {
public function __construct(Property $property, ISearchContext $search_context)
{
$this->property = $property;
$this->searchContext = $search_context;
$this->annotationManager = $annotation_manager;
}

/**
Expand Down
Expand Up @@ -58,7 +58,7 @@ public function __construct(ISearchContext $search_context, AnnotationManager $a
*/
public function createLocator(Property $property)
{
return new WaitingElementLocator($property, $this->searchContext, $this->annotationManager);
return new WaitingElementLocator($property, $this->searchContext);
}

}
Expand Up @@ -12,7 +12,6 @@


use Behat\Mink\Element\NodeElement;
use mindplay\annotations\AnnotationManager;
use QATools\QATools\PageObject\Annotation\TimeoutAnnotation;
use QATools\QATools\PageObject\ISearchContext;
use QATools\QATools\PageObject\Property;
Expand All @@ -35,16 +34,12 @@ class WaitingElementLocator extends DefaultElementLocator
/**
* Creates a new element locator.
*
* @param Property $property Property.
* @param ISearchContext $search_context The context to use when finding the element.
* @param AnnotationManager $annotation_manager Annotation manager.
* @param Property $property Property.
* @param ISearchContext $search_context The context to use when finding the element.
*/
public function __construct(
Property $property,
ISearchContext $search_context,
AnnotationManager $annotation_manager
) {
parent::__construct($property, $search_context, $annotation_manager);
public function __construct(Property $property, ISearchContext $search_context)
{
parent::__construct($property, $search_context);

/** @var TimeoutAnnotation[] $annotations */
$annotations = $property->getAnnotationsFromPropertyOrClass('@timeout');
Expand Down
Expand Up @@ -208,14 +208,13 @@ protected function createLocator(array $mock_methods = array())

return m::mock(
$class,
array($this->property, $this->searchContext, $this->annotationManager, $this->_locatorHelper)
array($this->property, $this->searchContext, $this->_locatorHelper)
);
}

return new $this->locatorClass(
$this->property,
$this->searchContext,
$this->annotationManager,
$this->_locatorHelper
);
}
Expand Down
Expand Up @@ -49,13 +49,6 @@ class DefaultElementLocatorTest extends TestCase
*/
protected $property;

/**
* Annotation manager.
*
* @var \Mockery\MockInterface
*/
protected $annotationManager;

/**
* Search context.
*
Expand All @@ -76,7 +69,6 @@ class DefaultElementLocatorTest extends TestCase
protected function setUpTest()
{
$this->property = m::mock(self::PROPERTY_CLASS);
$this->annotationManager = m::mock('\\mindplay\\annotations\\AnnotationManager');
$this->searchContext = m::mock($this->searchContextClass);

$this->locator = $this->createLocator();
Expand Down Expand Up @@ -220,10 +212,10 @@ protected function createLocator(array $mock_methods = array())
if ( $mock_methods ) {
$class = $this->locatorClass . '[' . implode(',', $mock_methods) . ']';

return m::mock($class, array($this->property, $this->searchContext, $this->annotationManager));
return m::mock($class, array($this->property, $this->searchContext));
}

return new $this->locatorClass($this->property, $this->searchContext, $this->annotationManager);
return new $this->locatorClass($this->property, $this->searchContext);
}

}

0 comments on commit 28a2b0d

Please sign in to comment.