Skip to content

Commit 13085d9

Browse files
committedMar 2, 2017
[Behat][Admin][Customer] Fixes after changes displaying statistics
1 parent 1d1c5d5 commit 13085d9

File tree

5 files changed

+9
-56
lines changed

5 files changed

+9
-56
lines changed
 

‎features/user/managing_customers/seeing_orders_statistics_on_customer_details_page.feature

-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ Feature: Seeing customer's orders' statistics
1717
When I view details of the customer "b.baggins@shire.me"
1818
Then I should see the customer has not placed any orders yet
1919

20-
@ui
21-
Scenario: Seeing customer's all placed orders count
22-
Given customer "lirael.clayr@abhorsen.ok" has placed 5 orders on the "Web-US" channel in each buying 3 "Onion" products
23-
And this customer has also placed 12 orders on the "Web-UK" channel in each buying 20 "Onion" products
24-
When I view their details
25-
Then I should see that they have placed 17 orders across all channels
26-
2720
@ui
2821
Scenario: Seeing how many orders the customer has placed in specific channel
2922
Given customer "lirael.clayr@abhorsen.ok" has placed 12 orders on the "Web-UK" channel in each buying 2 "Onion" products

‎src/Sylius/Behat/Context/Ui/Admin/ManagingCustomersContext.php

-8
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,6 @@ public function iShouldSeeTheCustomerHasNotYetPlacedAnyOrders()
618618
Assert::false($this->showPage->hasCustomerPlacedAnyOrders());
619619
}
620620

621-
/**
622-
* @Then /^I should see that they have placed (\d+) orders? across all channels$/
623-
*/
624-
public function iShouldSeeThatTheyHavePlacedOrdersAcrossAllChannels($orderCount)
625-
{
626-
Assert::same($this->showPage->getOverallOrdersCount(), (int) $orderCount);
627-
}
628-
629621
/**
630622
* @Then /^I should see that they have placed (\d+) orders? in the "([^"]+)" channel$/
631623
*/

‎src/Sylius/Behat/Page/Admin/Customer/ShowPage.php

+8-35
Original file line numberDiff line numberDiff line change
@@ -161,60 +161,40 @@ public function hasCustomerPlacedAnyOrders()
161161
return null !== $this->getElement('statistics')->find('css', '.sylius-orders-overall-count');
162162
}
163163

164-
/**
165-
* {@inheritdoc}
166-
*/
167-
public function getOverallOrdersCount()
168-
{
169-
$overallOrders = $this
170-
->getElement('statistics')
171-
->find('css', '.sylius-orders-overall-count')
172-
->getText()
173-
;
174-
175-
return (int) preg_replace('/[^0-9]/', '',$overallOrders);
176-
}
177-
178164
/**
179165
* {@inheritdoc}
180166
*/
181167
public function getOrdersCountInChannel($channelName)
182168
{
183-
$ordersCountStatistic = $this
169+
return (int) $this
184170
->getStatisticsForChannel($channelName)
185171
->find('css', '.sylius-orders-count')
186172
->getText()
187173
;
188-
189-
return (int) $this->getStatisticValue($ordersCountStatistic);
190174
}
191175

192176
/**
193177
* {@inheritdoc}
194178
*/
195179
public function getOrdersTotalInChannel($channelName)
196180
{
197-
$ordersCountStatistic = $this
181+
return $this
198182
->getStatisticsForChannel($channelName)
199183
->find('css', '.sylius-orders-total')
200184
->getText()
201185
;
202-
203-
return $this->getStatisticValue($ordersCountStatistic);
204186
}
205187

206188
/**
207189
* {@inheritdoc}
208190
*/
209191
public function getAverageTotalInChannel($channelName)
210192
{
211-
$averageTotalStatistic = $this
193+
return $this
212194
->getStatisticsForChannel($channelName)
213195
->find('css', '.sylius-order-average-total')
214196
->getText()
215197
;
216-
217-
return $this->getStatisticValue($averageTotalStatistic);
218198
}
219199

220200
/**
@@ -263,7 +243,10 @@ protected function getDefinedElements()
263243
*/
264244
private function getStatisticsForChannel($channelName)
265245
{
266-
$statisticsRibs = $this->getElement('statistics')->findAll('css', '.accordion > .title');
246+
$statisticsRibs = $this
247+
->getElement('statistics')
248+
->findAll('css', '.row > .column > .statistic > .sylius-channel-name')
249+
;
267250

268251
$statisticsRibs = array_filter($statisticsRibs, function (NodeElement $statistic) use ($channelName) {
269252
return $channelName === trim($statistic->getText());
@@ -280,19 +263,9 @@ private function getStatisticsForChannel($channelName)
280263
)
281264
);
282265

283-
$statisticsContents = $this->getElement('statistics')->findAll('css', '.accordion > .content');
266+
$statisticsContents = $this->getElement('statistics')->findAll('css', '.row');
284267
$contentIndexes = array_keys($statisticsRibs);
285268

286269
return $statisticsContents[reset($contentIndexes)];
287270
}
288-
289-
/**
290-
* @param string $statistic
291-
*
292-
* @return string
293-
*/
294-
private function getStatisticValue($statistic)
295-
{
296-
return trim(substr($statistic, strpos($statistic, ':') + 1));
297-
}
298271
}

‎src/Sylius/Behat/Page/Admin/Customer/ShowPageInterface.php

-5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ public function impersonate();
9393
*/
9494
public function hasCustomerPlacedAnyOrders();
9595

96-
/**
97-
* @return int
98-
*/
99-
public function getOverallOrdersCount();
100-
10196
/**
10297
* @param string $channelName
10398
*

‎src/Sylius/Bundle/AdminBundle/Resources/views/Customer/Show/Statistics/index.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %}
22

3-
<div class="ui segment">
3+
<div class="ui segment" id="statistics">
44
{% if statistics.perChannelsStatistics is not empty %}
55
<div class="ui center aligned stackable internally celled grid">
66
{% for statistic in statistics.perChannelsStatistics %}

0 commit comments

Comments
 (0)