1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Magium\Magento\Extractors\Catalog\Search; |
4
|
|
|
|
5
|
|
|
use Magium\AbstractTestCase; |
6
|
|
|
use Magium\Extractors\AbstractExtractor; |
7
|
|
|
use Magium\Magento\Themes\AbstractThemeConfiguration; |
8
|
|
|
use Magium\WebDriver\ExpectedCondition; |
9
|
|
|
use Magium\WebDriver\WebDriver; |
10
|
|
|
|
11
|
|
|
class SearchSuggestions extends AbstractExtractor |
12
|
|
|
{ |
13
|
|
|
const EXTRACTOR = 'Catalog\Search\SearchSuggestions'; |
14
|
|
|
|
15
|
|
|
protected $suggestions; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var AbstractThemeConfiguration |
19
|
|
|
*/ |
20
|
|
|
protected $theme; // Here for code completion assistance |
21
|
|
|
|
22
|
|
|
public function __construct(WebDriver $webDriver, AbstractTestCase $testCase, AbstractThemeConfiguration $theme) |
23
|
|
|
{ |
24
|
|
|
parent::__construct($webDriver, $testCase, $theme); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return SearchSuggestions[] |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
public function getSuggestions() |
32
|
|
|
{ |
33
|
|
|
return $this->suggestions; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function extract() |
37
|
|
|
{ |
38
|
|
|
$testXpath = $this->theme->getSearchSuggestionTextXpath(1); |
39
|
|
|
$this->webDriver->wait(5)->until(ExpectedCondition::elementExists($testXpath, WebDriver::BY_XPATH)); |
|
|
|
|
40
|
|
|
$testElement = $this->webDriver->byXpath($testXpath); |
41
|
|
|
$this->webDriver->wait(5)->until(ExpectedCondition::visibilityOf($testElement)); |
|
|
|
|
42
|
|
|
$count = 0; |
43
|
|
|
$this->suggestions = []; |
44
|
|
|
while ($this->webDriver->elementExists($this->theme->getSearchSuggestionTextXpath(++$count), WebDriver::BY_XPATH)) { |
45
|
|
|
$suggestionCount = trim($this->webDriver->byXpath($this->theme->getSearchSuggestionCountXpath($count))->getText()); |
46
|
|
|
$suggestionText = trim($this->webDriver->byXpath($this->theme->getSearchSuggestionTextXpath($count))->getText()); |
47
|
|
|
$suggestionText = trim($suggestionText, $suggestionCount); |
48
|
|
|
$this->suggestions[] = new SearchSuggestion( |
49
|
|
|
$this->webDriver->byXpath($this->theme->getSearchSuggestionTextXpath($count)), |
50
|
|
|
$suggestionCount, |
51
|
|
|
$suggestionText |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: