1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Magium\Magento\Actions\Checkout\PaymentMethods; |
4
|
|
|
|
5
|
|
|
use Facebook\WebDriver\WebDriverSelect; |
6
|
|
|
use Magium\Magento\AbstractMagentoTestCase; |
7
|
|
|
use Magium\Magento\Actions\Checkout\PaymentInformation; |
8
|
|
|
use Magium\Magento\Identities\Customer; |
9
|
|
|
use Magium\WebDriver\WebDriver; |
10
|
|
|
|
11
|
|
|
class SavedCC implements PaymentMethodInterface |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
const ACTION = 'Checkout\PaymentMethods\SavedCC'; |
15
|
|
|
|
16
|
|
|
protected $webDriver; |
17
|
|
|
protected $testCase; |
18
|
|
|
protected $paymentInformation; |
19
|
|
|
protected $customer; |
20
|
|
|
protected $assertion; |
21
|
|
|
|
22
|
|
|
public function __construct( |
23
|
|
|
WebDriver $webDriver, |
24
|
|
|
AbstractMagentoTestCase $testCase, |
25
|
|
|
PaymentInformation $paymentInformation, |
26
|
|
|
Customer $customer, |
27
|
|
|
\Magium\Magento\Assertions\Checkout\PaymentMethods\SavedCC $assertion |
28
|
|
|
) { |
29
|
|
|
$this->webDriver = $webDriver; |
30
|
|
|
$this->testCase = $testCase; |
31
|
|
|
$this->paymentInformation = $paymentInformation; |
32
|
|
|
$this->customer = $customer; |
33
|
|
|
$this->assertion = $assertion; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getId() |
37
|
|
|
{ |
38
|
|
|
return 'ccsave_cc_owner'; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function pay($requirePayment) |
42
|
|
|
{ |
43
|
|
|
if ($requirePayment) { |
44
|
|
|
$this->testCase->assertElementExists($this->getId()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if ($this->webDriver->elementDisplayed($this->getId())) { |
48
|
|
|
$this->webDriver->byId($this->getId())->click(); |
49
|
|
|
} |
50
|
|
|
$this->assertion->assert(); |
51
|
|
|
|
52
|
|
|
$this->webDriver->byId('ccsave_cc_owner')->clear(); |
53
|
|
|
$this->webDriver->byId('ccsave_cc_owner')->sendKeys( |
54
|
|
|
$this->customer->getBillingFirstName() . ' ' . $this->customer->getBillingLastName() |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$select = new WebDriverSelect($this->webDriver->byId('ccsave_cc_type')); |
58
|
|
|
$select->selectByValue($this->paymentInformation->getType()); |
59
|
|
|
|
60
|
|
|
$this->webDriver->byId('ccsave_cc_number')->clear(); |
61
|
|
|
$this->webDriver->byId('ccsave_cc_number')->sendKeys($this->paymentInformation->getCreditCardNumber()); |
62
|
|
|
|
63
|
|
|
$select = new WebDriverSelect($this->webDriver->byId('ccsave_expiration')); |
64
|
|
|
$select->selectByValue($this->paymentInformation->getExpiryMonth()); |
65
|
|
|
|
66
|
|
|
$select = new WebDriverSelect($this->webDriver->byId('ccsave_expiration_yr')); |
67
|
|
|
$select->selectByValue($this->paymentInformation->getExpiryYear()); |
68
|
|
|
|
69
|
|
|
} |
70
|
|
|
} |