Skip to content

Commit 35dc404

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-62624' into 2.0-develop-pr6
2 parents 8baeb26 + 658af7e commit 35dc404

File tree

2 files changed

+87
-16
lines changed

2 files changed

+87
-16
lines changed

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class Create extends Block
121121
public function getItemsBlock()
122122
{
123123
return $this->blockFactory->create(
124-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Items',
124+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Items::class,
125125
['element' => $this->_rootElement->find($this->itemsBlock, Locator::SELECTOR_CSS)]
126126
);
127127
}
@@ -134,7 +134,7 @@ public function getItemsBlock()
134134
public function getBillingAddressBlock()
135135
{
136136
return $this->blockFactory->create(
137-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Address',
137+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Address::class,
138138
['element' => $this->_rootElement->find($this->billingAddressBlock, Locator::SELECTOR_CSS)]
139139
);
140140
}
@@ -147,7 +147,7 @@ public function getBillingAddressBlock()
147147
protected function getShippingAddressBlock()
148148
{
149149
return $this->blockFactory->create(
150-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Address',
150+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Address::class,
151151
['element' => $this->_rootElement->find($this->shippingAddressBlock, Locator::SELECTOR_CSS)]
152152
);
153153
}
@@ -160,7 +160,7 @@ protected function getShippingAddressBlock()
160160
protected function getBillingMethodBlock()
161161
{
162162
return $this->blockFactory->create(
163-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Method',
163+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Billing\Method::class,
164164
['element' => $this->_rootElement->find($this->billingMethodBlock, Locator::SELECTOR_CSS)]
165165
);
166166
}
@@ -173,7 +173,7 @@ protected function getBillingMethodBlock()
173173
protected function getShippingMethodBlock()
174174
{
175175
return $this->blockFactory->create(
176-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Method',
176+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Shipping\Method::class,
177177
['element' => $this->_rootElement->find($this->shippingMethodBlock, Locator::SELECTOR_CSS)]
178178
);
179179
}
@@ -183,10 +183,10 @@ protected function getShippingMethodBlock()
183183
*
184184
* @return \Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals
185185
*/
186-
protected function getTotalsBlock()
186+
public function getTotalsBlock()
187187
{
188188
return $this->blockFactory->create(
189-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals',
189+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals::class,
190190
['element' => $this->_rootElement->find($this->totalsBlock, Locator::SELECTOR_CSS)]
191191
);
192192
}
@@ -199,7 +199,7 @@ protected function getTotalsBlock()
199199
public function getTemplateBlock()
200200
{
201201
return $this->blockFactory->create(
202-
'Magento\Backend\Test\Block\Template',
202+
\Magento\Backend\Test\Block\Template::class,
203203
['element' => $this->_rootElement->find($this->templateBlock, Locator::SELECTOR_XPATH)]
204204
);
205205
}
@@ -212,7 +212,7 @@ public function getTemplateBlock()
212212
public function getGridBlock()
213213
{
214214
return $this->blockFactory->create(
215-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Search\Grid',
215+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Search\Grid::class,
216216
['element' => $this->_rootElement->find($this->gridBlock, Locator::SELECTOR_CSS)]
217217
);
218218
}
@@ -225,7 +225,7 @@ public function getGridBlock()
225225
public function getAccountBlock()
226226
{
227227
return $this->blockFactory->create(
228-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Form\Account',
228+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Form\Account::class,
229229
['element' => $this->_rootElement->find($this->accountInformationBlock, Locator::SELECTOR_CSS)]
230230
);
231231
}
@@ -250,7 +250,7 @@ public function updateProductsData(array $products)
250250
{
251251
/** @var \Magento\Sales\Test\Block\Adminhtml\Order\Create\Items $items */
252252
$items = $this->blockFactory->create(
253-
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Items',
253+
\Magento\Sales\Test\Block\Adminhtml\Order\Create\Items::class,
254254
['element' => $this->_rootElement->find($this->itemsBlock)]
255255
);
256256
foreach ($products as $product) {

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Totals.php

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,97 @@
77
namespace Magento\Sales\Test\Block\Adminhtml\Order\Create;
88

99
use Magento\Mtf\Block\Block;
10+
use Magento\Mtf\Client\Locator;
1011

1112
/**
12-
* Class Totals
13-
* Adminhtml sales order create totals block
14-
*
13+
* Adminhtml sales order create totals block.
1514
*/
1615
class Totals extends Block
1716
{
1817
/**
19-
* 'Submit Order' button
18+
* 'Submit Order' button.
2019
*
2120
* @var string
2221
*/
2322
protected $submitOrder = '.order-totals-actions button';
2423

2524
/**
26-
* Click 'Submit Order' button
25+
* Order totals table.
26+
*
27+
* @var string
28+
*/
29+
protected $totalsTable = '.data-table';
30+
31+
/**
32+
* Total row label selector.
33+
*
34+
* @var string
35+
*/
36+
protected $totalLabelLocator = './/tr[normalize-space(td)="%s"]';
37+
38+
/**
39+
* Total value selector.
40+
*
41+
* @var string
42+
*/
43+
protected $totalValueLocator = './/td/span[contains(@class,"price")]';
44+
45+
/**
46+
* Click 'Submit Order' button.
2747
*/
2848
public function submitOrder()
2949
{
3050
$this->_rootElement->find($this->submitOrder)->click();
3151
}
52+
53+
/**
54+
* Return totals by labels.
55+
*
56+
* @param $totals string[]
57+
* @return array
58+
*/
59+
public function getTotals($totals)
60+
{
61+
if (empty ($totals)) {
62+
return [];
63+
}
64+
65+
$totalsResult = [];
66+
$totalsTable = $this->_rootElement->find($this->totalsTable);
67+
68+
foreach ($totals as $total) {
69+
70+
$totalRow = $totalsTable->find(sprintf($this->totalLabelLocator, $total), Locator::SELECTOR_XPATH);
71+
if ($totalRow->isVisible()) {
72+
$totalValue = $totalRow->find($this->totalValueLocator, Locator::SELECTOR_XPATH);
73+
$totalsResult[$total] = $this->escapeNumericValue($totalValue->getText());
74+
}
75+
}
76+
77+
return $totalsResult;
78+
}
79+
80+
/**
81+
* Return total presence by label.
82+
*
83+
* @param string $total
84+
* @return bool
85+
*/
86+
public function isTotalPresent($total)
87+
{
88+
$totalsTable = $this->_rootElement->find($this->totalsTable);
89+
$totalRow = $totalsTable->find(sprintf($this->totalLabelLocator, $total), Locator::SELECTOR_XPATH);
90+
return $totalRow->isVisible();
91+
}
92+
93+
/**
94+
* Escape numeric value.
95+
*
96+
* @param string $value
97+
* @return mixed
98+
*/
99+
private function escapeNumericValue($value)
100+
{
101+
return preg_replace("/[^-0-9\\.]/", "", $value);
102+
}
32103
}

0 commit comments

Comments
 (0)