|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Magium\Magento\Actions\Checkout\ShippingMethods; |
|
4
|
|
|
|
|
5
|
|
|
use Facebook\WebDriver\WebDriverBy; |
|
6
|
|
|
use Magium\AbstractTestCase; |
|
7
|
|
|
use Magium\Magento\AbstractMagentoTestCase; |
|
8
|
|
|
use Magium\Magento\Themes\OnePageCheckout\AbstractThemeConfiguration; |
|
9
|
|
|
use Magium\WebDriver\ExpectedCondition; |
|
10
|
|
|
use Magium\WebDriver\WebDriver; |
|
11
|
|
|
|
|
12
|
|
|
class FirstAvailable implements ShippingMethodInterface |
|
13
|
|
|
{ |
|
14
|
|
|
const ACTION = 'Checkout\ShippingMethods\FirstAvailable'; |
|
15
|
|
|
protected $webDriver; |
|
16
|
|
|
protected $theme; |
|
17
|
|
|
protected $testCase; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct( |
|
20
|
|
|
WebDriver $webDriver, |
|
21
|
|
|
AbstractThemeConfiguration $theme, |
|
22
|
|
|
AbstractMagentoTestCase $testCase |
|
23
|
|
|
) { |
|
24
|
|
|
$this->webDriver = $webDriver; |
|
25
|
|
|
$this->theme = $theme; |
|
26
|
|
|
$this->testCase = $testCase; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function choose($required) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->webDriver->wait()->until( |
|
32
|
|
|
ExpectedCondition::elementExists( |
|
|
|
|
|
|
33
|
|
|
$this->theme->getShippingMethodFormXpath(), AbstractTestCase::BY_XPATH |
|
34
|
|
|
) |
|
35
|
|
|
); |
|
36
|
|
|
|
|
37
|
|
|
// Some products, such as virtual products, do not get shipped |
|
38
|
|
|
if ($required) { |
|
39
|
|
|
$this->testCase->assertElementExists($this->theme->getDefaultShippingXpath(), AbstractTestCase::BY_XPATH); |
|
40
|
|
|
$this->testCase->assertElementDisplayed($this->theme->getDefaultShippingXpath(), AbstractTestCase::BY_XPATH); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if ($this->webDriver->elementDisplayed($this->theme->getDefaultShippingXpath(), AbstractTestCase::BY_XPATH)) { |
|
44
|
|
|
$xpath = $this->theme->getDefaultShippingXpath(); |
|
45
|
|
|
$element = $this->webDriver->byXpath($xpath); |
|
46
|
|
|
$this->webDriver->action()->moveToElement($element); |
|
47
|
|
|
$this->webDriver->wait()->until(ExpectedCondition::elementToBeClickable(WebDriverBy::xpath($xpath))); |
|
|
|
|
|
|
48
|
|
|
$this->webDriver->byXpath($xpath)->click(); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
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: