Conditions | 1 |
Paths | 1 |
Total Lines | 96 |
Code Lines | 69 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
74 | public function testShipmentCanBeCreatedWithTracking() |
||
75 | { |
||
76 | $this->orderModel |
||
77 | ->expects($this->once()) |
||
78 | ->method('loadByIncrementId') |
||
79 | ->with(5); |
||
80 | |||
81 | $this->orderModel |
||
82 | ->expects($this->any()) |
||
83 | ->method('getId') |
||
84 | ->will($this->returnValue(5)); |
||
85 | |||
86 | $shipment = $this->getMock('Mage_Sales_Model_Order_Shipment'); |
||
87 | |||
88 | $this->orderModel |
||
89 | ->expects($this->once()) |
||
90 | ->method('prepareShipment') |
||
91 | ->will($this->returnValue($shipment)); |
||
92 | |||
93 | $shipment |
||
94 | ->expects($this->once()) |
||
95 | ->method('register'); |
||
96 | |||
97 | $shipment |
||
98 | ->expects($this->any()) |
||
99 | ->method('getOrder') |
||
100 | ->will($this->returnValue($this->orderModel)); |
||
101 | |||
102 | $this->orderModel |
||
103 | ->expects($this->once()) |
||
104 | ->method('setData') |
||
105 | ->with('is_in_process', true); |
||
106 | |||
107 | $this->transactionResourceModel |
||
108 | ->expects($this->at(0)) |
||
109 | ->method('addObject') |
||
110 | ->with($shipment) |
||
111 | ->will($this->returnSelf()); |
||
112 | |||
113 | $this->transactionResourceModel |
||
114 | ->expects($this->at(1)) |
||
115 | ->method('addObject') |
||
116 | ->with($this->orderModel) |
||
117 | ->will($this->returnSelf()); |
||
118 | |||
119 | $this->transactionResourceModel |
||
120 | ->expects($this->once()) |
||
121 | ->method('save'); |
||
122 | |||
123 | $this->trackingModel |
||
124 | ->expects($this->once()) |
||
125 | ->method('setShipment') |
||
126 | ->with($shipment); |
||
127 | |||
128 | $this->trackingModel |
||
129 | ->expects($this->once()) |
||
130 | ->method('setData') |
||
131 | ->with( |
||
132 | [ |
||
133 | 'title' => 'Test Carrier', |
||
134 | 'number' => '782773742', |
||
135 | 'carrier_code' => 'custom', |
||
136 | 'order_id' => 5 |
||
137 | ] |
||
138 | ); |
||
139 | |||
140 | $this->trackingModel |
||
141 | ->expects($this->once()) |
||
142 | ->method('save'); |
||
143 | |||
144 | $this->shipmentWriter->writeItem( |
||
145 | [ |
||
146 | 'tracks' => [ |
||
147 | 0 => [ |
||
148 | 'carrier' => 'Test Carrier', |
||
149 | 'tracking_number' => '782773742' |
||
150 | ] |
||
151 | ], |
||
152 | 'items' => [ |
||
153 | 'items' => [ |
||
154 | 0 => [ |
||
155 | 'LineNo' => 70000, |
||
156 | 'SKU' => 'FILAM317RL1', |
||
157 | 'Qty' => 1 |
||
158 | ], |
||
159 | 1 => [ |
||
160 | 'LineNo' => 70001, |
||
161 | 'SKU' => 'FILAM317RL2', |
||
162 | 'Qty' => 1 |
||
163 | ] |
||
164 | ] |
||
165 | ], |
||
166 | 'order_id' => 5 |
||
167 | ] |
||
168 | ); |
||
169 | } |
||
170 | |||
320 |