Conditions | 1 |
Paths | 1 |
Total Lines | 96 |
Code Lines | 79 |
Lines | 0 |
Ratio | 0 % |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
38 | public function testPost() |
||
39 | { |
||
40 | $user = $this->getUser(); |
||
41 | |||
42 | $request = [ |
||
43 | 'subTotal' => 100, |
||
44 | 'grandTotal' => 100, |
||
45 | 'taxAmount' => 10, |
||
46 | 'cartItems' => [ |
||
47 | [ |
||
48 | 'sku' => 'some sku', |
||
49 | 'name' => 'some name', |
||
50 | 'qty' => 10, |
||
51 | 'price' => 100, |
||
52 | 'discountAmount' => 10, |
||
53 | 'taxPercent' => 5, |
||
54 | 'weight' => 1, |
||
55 | 'productId' => 100500, |
||
56 | 'parentItemId' => 100499, |
||
57 | 'freeShipping' => 'nope', |
||
58 | 'giftMessage' => 'some gift', |
||
59 | 'taxClassId' => 'some tax', |
||
60 | 'description' => '', |
||
61 | 'isVirtual' => true, |
||
62 | 'customPrice' => 100, |
||
63 | 'priceInclTax' => 100, |
||
64 | 'rowTotal' => 100, |
||
65 | 'taxAmount' => 10, |
||
66 | 'productType' => 'some type' |
||
67 | ] |
||
68 | ], |
||
69 | 'customer' => $this->getCustomer()->getId(), |
||
70 | 'store' => $this->getStore()->getId(), |
||
71 | 'itemsQty' => 100, |
||
72 | 'baseCurrencyCode' => 'some text', |
||
73 | 'storeCurrencyCode' => 'some text 2', |
||
74 | 'quoteCurrencyCode' => 'some text 3', |
||
75 | 'storeToBaseRate' => 10, |
||
76 | 'storeToQuoteRate' => 10, |
||
77 | 'email' => '[email protected]', |
||
78 | 'giftMessage' => 'some message', |
||
79 | 'isGuest' => true, |
||
80 | 'shippingAddress' => [ |
||
81 | 'label' => 'new1', |
||
82 | 'street' => 'street', |
||
83 | 'city' => 'new city', |
||
84 | 'postalCode' => '10000', |
||
85 | 'country' => 'US', |
||
86 | 'region' => 'US-AL', |
||
87 | 'firstName' => 'first', |
||
88 | 'lastName' => 'last', |
||
89 | 'nameSuffix' => 'suffix', |
||
90 | 'phone' => '123123123' |
||
91 | ], |
||
92 | 'billingAddress' => [ |
||
93 | 'label' => 'new2', |
||
94 | 'street' => 'street', |
||
95 | 'city' => 'new city', |
||
96 | 'postalCode' => '10000', |
||
97 | 'country' => 'US', |
||
98 | 'region' => 'US-AL', |
||
99 | 'firstName' => 'first', |
||
100 | 'lastName' => 'last', |
||
101 | 'nameSuffix' => 'suffix', |
||
102 | 'phone' => '123123123' |
||
103 | ], |
||
104 | 'paymentDetails' => 'some details', |
||
105 | 'status' => 'open', |
||
106 | 'notes' => 'some text 4', |
||
107 | 'statusMessage' => 'some text 5', |
||
108 | 'owner' => $user->getId(), |
||
109 | 'dataChannel' => $this->getChannel()->getId(), |
||
110 | 'channel' => $this->getChannel()->getDataSource()->getId() |
||
111 | ]; |
||
112 | |||
113 | $this->client->request('POST', $this->getUrl('oro_api_post_cart'), $request); |
||
114 | |||
115 | $result = $this->getJsonResponseContent($this->client->getResponse(), 201); |
||
116 | |||
117 | $this->assertArrayHasKey('id', $result); |
||
118 | $this->assertNotEmpty($result['id']); |
||
119 | |||
120 | $this->client->request('GET', $this->getUrl('oro_api_get_cart', ['id' => $result['id']])); |
||
121 | |||
122 | /** @var Cart $cart */ |
||
123 | $cart = $this->getJsonResponseContent($this->client->getResponse(), 200); |
||
124 | |||
125 | $this->assertCount(1, $cart['cartItems']); |
||
126 | $this->assertNotEmpty($cart['billingAddress']); |
||
127 | $this->assertInternalType('array', $cart['billingAddress']); |
||
128 | $this->assertNotEmpty($cart['shippingAddress']); |
||
129 | $this->assertInternalType('array', $cart['shippingAddress']); |
||
130 | $this->assertEquals(1, $cart['itemsCount']); |
||
131 | |||
132 | return $cart; |
||
133 | } |
||
134 | |||
253 |