|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Magium\Magento\Extractors\Customer\Order; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use Facebook\WebDriver\WebDriverElement; |
|
7
|
|
|
use Magium\Extractors\DateTime; |
|
8
|
|
|
use Magium\Magento\AbstractMagentoTestCase; |
|
9
|
|
|
use Magium\Magento\Themes\Customer\AbstractThemeConfiguration; |
|
10
|
|
|
use Magium\WebDriver\WebDriver; |
|
11
|
|
|
|
|
12
|
|
|
class Summary extends AbstractOrderExtractor |
|
13
|
|
|
{ |
|
14
|
|
|
const EXTRACTOR = 'Customer\Order\Summary'; |
|
15
|
|
|
|
|
16
|
|
|
protected $element; |
|
17
|
|
|
protected $dateTime; |
|
18
|
|
|
|
|
19
|
|
|
protected $orderDate; |
|
20
|
|
|
protected $subTotal; |
|
21
|
|
|
protected $shippingAndHandling; |
|
22
|
|
|
protected $tax; |
|
23
|
|
|
protected $grandTotal; |
|
24
|
|
|
protected $status; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct(WebDriver $webDriver, AbstractMagentoTestCase $testCase, AbstractThemeConfiguration $theme, DateTime $dateTime) |
|
27
|
|
|
{ |
|
28
|
|
|
parent::__construct($webDriver, $testCase, $theme); |
|
29
|
|
|
$this->dateTime = $dateTime; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
public function getOrderDate() |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->orderDate; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function getSubTotal() |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->subTotal; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function getShippingAndHandling() |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->shippingAndHandling; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getTax() |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->tax; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function getGrandTotal() |
|
54
|
|
|
{ |
|
55
|
|
|
return $this->grandTotal; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getStatus() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->status; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function extract() |
|
64
|
|
|
{ |
|
65
|
|
|
if ($this->element instanceof WebDriverElement && $this->webDriver->elementAttached($this->element)) { |
|
66
|
|
|
return; |
|
67
|
|
|
} |
|
68
|
|
|
$this->element = $this->webDriver->byXpath('//body'); // Just need any element on the page |
|
69
|
|
|
$this->grandTotal = trim($this->webDriver->byXpath($this->theme->getOrderGrandTotalXpath())->getText()); |
|
70
|
|
|
$this->subTotal = trim($this->webDriver->byXpath($this->theme->getOrderSubtotalXpath())->getText()); |
|
71
|
|
|
$this->tax = trim($this->webDriver->byXpath($this->theme->getOrderTaxXpath())->getText()); |
|
72
|
|
|
$this->shippingAndHandling = trim($this->webDriver->byXpath($this->theme->getOrderShippingAndHandlingXpath())->getText()); |
|
73
|
|
|
$dateText = trim($this->webDriver->byXpath($this->theme->getOrderDateXpath())->getText()); |
|
74
|
|
|
$this->dateTime->setText($dateText); |
|
75
|
|
|
$this->dateTime->extract(); |
|
76
|
|
|
$this->orderDate = $this->dateTime->getDateString(); |
|
77
|
|
|
|
|
78
|
|
|
$statusText = $this->webDriver->byXpath($this->theme->getOrderStatusXpath())->getText(); |
|
79
|
|
|
$matches = null; |
|
80
|
|
|
if (preg_match($this->theme->getOrderStatusRegex(), $statusText, $matches)) { |
|
81
|
|
|
$this->status = $matches[1]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
} |