Completed
Push — master ( d54afb...01173a )
by Kamil
26:45
created

DashboardPage::getNumberOfNewOrdersInTheList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Behat\Page\Admin;
13
14
use Behat\Mink\Session;
15
use Sylius\Behat\Page\SymfonyPage;
16
use Sylius\Behat\Service\Accessor\TableAccessorInterface;
17
use Symfony\Component\Routing\RouterInterface;
18
19
/**
20
 * @author Paweł Jędrzejewski <[email protected]>
21
 */
22
class DashboardPage extends SymfonyPage implements DashboardPageInterface
23
{
24
    /**
25
     * @var TableAccessorInterface
26
     */
27
    private $tableAccessor;
28
29
    /**
30
     * @param TableAccessorInterface $tableAccessor
31
     */
32
    public function __construct(
33
        Session $session,
34
        array $parameters,
35
        RouterInterface $router,
36
        TableAccessorInterface $tableAccessor
37
    ) {
38
        parent::__construct($session, $parameters, $router);
39
40
        $this->tableAccessor = $tableAccessor;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getTotalSales()
47
    {
48
        return $this->getElement('total_sales')->getText();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getNumberOfNewOrders()
55
    {
56
        return (int) $this->getElement('new_orders')->getText();
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function getNumberOfNewOrdersInTheList()
63
    {
64
        return $this->tableAccessor->countTableBodyRows($this->getElement('order_list'));
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function getNumberOfNewCustomers()
71
    {
72
        return (int) $this->getElement('new_customers')->getText();
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function getNumberOfNewCustomersInTheList()
79
    {
80
        return $this->tableAccessor->countTableBodyRows($this->getElement('customer_list'));
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function getAverageOrderValue()
87
    {
88
        return $this->getElement('average_order_value')->getText();
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function getRouteName()
95
    {
96
        return 'sylius_admin_dashboard';
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    protected function getDefinedElements()
103
    {
104
        return array_merge(parent::getDefinedElements(), [
105
            'total_sales' => '#total-sales',
106
            'new_orders' => '#new-orders',
107
            'new_customers' => '#new-customers',
108
            'average_order_value' => '#average-order-value',
109
            'customer_list' => '#customers',
110
            'order_list' => '#orders',
111
        ]);
112
    }
113
}
114