Completed
Push — master ( c2123c...66812a )
by
unknown
12:37
created

OrderControllerTest::gridProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 81
Code Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 81
rs 8.8076
c 0
b 0
f 0
cc 1
eloc 53
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\Tests\Functional\Controller;
4
5
/**
6
 * @outputBuffering enabled
7
 * @dbIsolation
8
 */
9
class OrderControllerTest extends AbstractController
10
{
11
    /** @var \OroCRM\Bundle\MagentoBundle\Entity\Order */
12
    public static $order;
13
14
    protected function postFixtureLoad()
15
    {
16
        parent::postFixtureLoad();
17
18
        self::$order = $this->getReference('order');
19
    }
20
21
    protected function getMainEntityId()
22
    {
23
        return self::$order->getid();
24
    }
25
26
    public function testView()
27
    {
28
        $this->client->request('GET', $this->getUrl('orocrm_magento_order_view', ['id' => $this->getMainEntityId()]));
29
        $result = $this->client->getResponse();
30
        $this->assertHtmlResponseStatusCodeEquals($result, 200);
31
        $this->assertContains('Orders', $result->getContent());
32
        $this->assertContains('General Information', $result->getContent());
33
        $this->assertContains('Order items', $result->getContent());
34
        $this->assertContains('Activity', $result->getContent());
35
        $this->assertContains('Send email', $result->getContent());
36
        $this->assertContains('Sync Data', $result->getContent());
37
        $this->assertContains('$4.40', $result->getContent());
38
        $this->assertContains('open', $result->getContent());
39
        $this->assertContains('[email protected]', $result->getContent());
40
        $this->assertContains('$12.47', $result->getContent());
41
        $this->assertContains('$5.00', $result->getContent());
42
        $this->assertContains('$17.85', $result->getContent());
43
        $this->assertContains('$11.00', $result->getContent());
44
        $this->assertContains('$4.00', $result->getContent());
45
        $this->assertContains('$0.00', $result->getContent());
46
        $this->assertContains('Some unique shipping method', $result->getContent());
47
        $this->assertContains('127.0.0.1', $result->getContent());
48
        $this->assertContains('some very unique gift message', $result->getContent());
49
        $this->assertContains('web site', $result->getContent());
50
        $this->assertContains('Demo Web store', $result->getContent());
51
        $this->assertContains('John Doe', $result->getContent());
52
        $this->assertContains('Shopping Cart', $result->getContent());
53
    }
54
55
    public function gridProvider()
56
    {
57
        return [
58
            'Magento order grid'                             => [
59
                [
60
                    'gridParameters'      => [
61
                        'gridName' => 'magento-order-grid'
62
                    ],
63
                    'gridFilters'         => [],
64
                    'asserts' => [
65
                        [
66
                            'channelName' => 'Magento channel',
67
                            'firstName'   => 'John',
68
                            'lastName'    => 'Doe',
69
                            'status'      => 'open',
70
                            'subTotal'    => '$0.00',
71
                        ],
72
                        [
73
                            'channelName' => 'Magento channel',
74
                            'firstName'   => 'Guest Jack',
75
                            'lastName'    => 'Guest White',
76
                            'status'      => 'open',
77
                            'subTotal'    => '$0.00',
78
                        ]
79
                    ],
80
                    'expectedResultCount' => 2
81
                ],
82
            ],
83
            'Magento order grid with filters'                => [
84
                [
85
                    'gridParameters'      => [
86
                        'gridName' => 'magento-order-grid'
87
                    ],
88
                    'gridFilters'         => [
89
                        'magento-order-grid[_filter][lastName][value]'  => 'Doe',
90
                        'magento-order-grid[_filter][firstName][value]' => 'John',
91
                        'magento-order-grid[_filter][status][value]'    => 'open',
92
                    ],
93
                    'assert'              => [
94
                        'channelName' => 'Magento channel',
95
                        'firstName'   => 'John',
96
                        'lastName'    => 'Doe',
97
                        'status'      => 'open',
98
                        'subTotal'    => '$0.00',
99
                    ],
100
                    'expectedResultCount' => 1
101
                ],
102
            ],
103
            'Magento order grid with filters without result' => [
104
                [
105
                    'gridParameters'      => [
106
                        'gridName' => 'magento-order-grid'
107
                    ],
108
                    'gridFilters'         => [
109
                        'magento-order-grid[_filter][lastName][value]'  => 'Doe',
110
                        'magento-order-grid[_filter][firstName][value]' => 'John',
111
                        'magento-order-grid[_filter][status][value]'    => 'close',
112
                    ],
113
                    'assert'              => [],
114
                    'expectedResultCount' => 0
115
                ],
116
            ],
117
            'Magento order item grid'                        => [
118
                [
119
                    'gridParameters'      => [
120
                        'gridName' => 'magento-orderitem-grid',
121
                        'id'       => 'id',
122
                    ],
123
                    'gridFilters'         => [],
124
                    'assert'              => [
125
                        'sku'            => 'some sku',
126
                        'qty'            => 1,
127
                        'rowTotal'       => '$234.00',
128
                        'taxAmount'      => '$1.50',
129
                        'discountAmount' => '$0.00'
130
                    ],
131
                    'expectedResultCount' => 1
132
                ],
133
            ],
134
        ];
135
    }
136
}
137