Conditions | 1 |
Paths | 1 |
Total Lines | 99 |
Code Lines | 84 |
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 |
||
128 | function testState() |
||
129 | { |
||
130 | $procurement = new Procurement($this->createKernel()); |
||
131 | $procurement->update(array('dk_invoice_date' => '01-01-'.date('Y'), 'delivery_date' => '02-01-'.date('Y'), 'dk_payment_date' => '03-01-'.date('Y'), 'number' => 1, 'description' => 'test', 'dk_price_items' => '100,00', 'dk_price_shipment_etc' => '40,00', 'dk_vat' => '25,00')); |
||
132 | $year = $this->createAccountingYear(); |
||
133 | $procurement->setPaid('04-01-'.date('Y')); |
||
134 | |||
135 | $state = array( |
||
136 | 0 => array('text' => '', 'amount' => '100,00', 'state_account_id' => 7000), |
||
137 | 1 => array('text' => 'shipment_etc', 'amount' => '40,00', 'state_account_id' => 7200) |
||
138 | |||
139 | ); |
||
140 | |||
141 | $this->assertTrue($procurement->state($year, 1, '05-01-'.date('Y'), $state, 58000, new Stub_Translation), $procurement->error->view()); |
||
142 | |||
143 | $voucher = Voucher::factory($year, 1); |
||
144 | $expected = array( |
||
145 | 0 => array( |
||
146 | 'id' => 1, |
||
147 | 'date_dk' => '05-01-' . date('Y'), |
||
148 | 'date' => date('Y') . '-01-05', |
||
149 | 'text' => 'procurement# 1: test - købsmoms', |
||
150 | 'debet' => '25.00', |
||
151 | 'credit' => '0.00', |
||
152 | 'voucher_number' => 1, |
||
153 | 'reference' => '', |
||
154 | 'voucher_id' => 1, |
||
155 | 'account_id' => 44, |
||
156 | 'stated' => 1, |
||
157 | 'account_number' => '66100', |
||
158 | 'account_name' => 'Moms, indgående, køb' |
||
159 | ), |
||
160 | 1 => array( |
||
161 | 'id' => 2, |
||
162 | 'date_dk' => '05-01-' . date('Y'), |
||
163 | 'date' => date('Y') . '-01-05', |
||
164 | 'text' => 'procurement# 1: test', |
||
165 | 'debet' => '100.00', |
||
166 | 'credit' => '0.00', |
||
167 | 'voucher_number' => 1, |
||
168 | 'reference' => '', |
||
169 | 'voucher_id' => 1, |
||
170 | 'account_id' => 10, |
||
171 | 'stated' => 1, |
||
172 | 'account_number' => '7000', |
||
173 | 'account_name' => 'Kontorartikler' |
||
174 | ), |
||
175 | 2 => array( |
||
176 | 'id' => 3, |
||
177 | 'date_dk' => '05-01-' . date('Y'), |
||
178 | 'date' => date('Y') . '-01-05', |
||
179 | 'text' => 'procurement# 1: test', |
||
180 | 'debet' => '0.00', |
||
181 | 'credit' => '125.00', |
||
182 | 'voucher_number' => 1, |
||
183 | 'reference' => '', |
||
184 | 'voucher_id' => 1, |
||
185 | 'account_id' => 33, |
||
186 | 'stated' => 1, |
||
187 | 'account_number' => '58000', |
||
188 | 'account_name' => 'Bank, folio' |
||
189 | ), |
||
190 | 3 => array( |
||
191 | 'id' => 4, |
||
192 | 'date_dk' => '05-01-' . date('Y'), |
||
193 | 'date' => date('Y') . '-01-05', |
||
194 | 'text' => 'procurement# 1: test - shipment_etc', |
||
195 | 'debet' => '40.00', |
||
196 | 'credit' => '0.00', |
||
197 | 'voucher_number' => 1, |
||
198 | 'reference' => '', |
||
199 | 'voucher_id' => 1, |
||
200 | 'account_id' => 11, |
||
201 | 'stated' => 1, |
||
202 | 'account_number' => '7200', |
||
203 | 'account_name' => 'Porto' |
||
204 | ), |
||
205 | 4 => array( |
||
206 | 'id' => 5, |
||
207 | 'date_dk' => '05-01-' . date('Y'), |
||
208 | 'date' => date('Y') . '-01-05', |
||
209 | 'text' => 'procurement# 1: test - shipment_etc', |
||
210 | 'debet' => '0.00', |
||
211 | 'credit' => '40.00', |
||
212 | 'voucher_number' => 1, |
||
213 | 'reference' => '', |
||
214 | 'voucher_id' => 1, |
||
215 | 'account_id' => 33, |
||
216 | 'stated' => 1, |
||
217 | 'account_number' => '58000', |
||
218 | 'account_name' => 'Bank, folio' |
||
219 | ) |
||
220 | ); |
||
221 | |||
222 | $this->assertEquals($expected, $voucher->getPosts()); |
||
223 | |||
224 | $this->assertTrue($procurement->isStated()); |
||
225 | $this->assertFalse($procurement->readyForState($year)); |
||
226 | } |
||
227 | |||
244 |
This check marks private properties in classes that are never used. Those properties can be removed.