Total Complexity | 89 |
Total Lines | 460 |
Duplicated Lines | 0 % |
Changes | 31 | ||
Bugs | 2 | Features | 6 |
Complex classes like EntityTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EntityTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
12 | class EntityTest extends TestCase |
||
13 | { |
||
14 | |||
15 | public function testAccountEntity() |
||
16 | { |
||
17 | $this->performEntityTest(\Picqer\Financials\Exact\Account::class); |
||
18 | } |
||
19 | |||
20 | public function testAccountClassificationEntity() |
||
23 | } |
||
24 | |||
25 | public function testAccountInvolvedAccountEntity() |
||
26 | { |
||
27 | $this->performEntityTest(\Picqer\Financials\Exact\AccountInvolvedAccount::class); |
||
28 | } |
||
29 | |||
30 | public function testAccountItemEntity() |
||
31 | { |
||
32 | $this->performEntityTest(\Picqer\Financials\Exact\AccountItem::class); |
||
33 | } |
||
34 | |||
35 | public function testAddressEntity() |
||
36 | { |
||
37 | $this->performEntityTest(\Picqer\Financials\Exact\Address::class); |
||
38 | } |
||
39 | |||
40 | public function testBankAccountEntity() |
||
41 | { |
||
42 | $this->performEntityTest(\Picqer\Financials\Exact\BankAccount::class); |
||
43 | } |
||
44 | |||
45 | public function testBankEntity() |
||
46 | { |
||
47 | $this->performEntityTest(\Picqer\Financials\Exact\Bank::class); |
||
48 | } |
||
49 | |||
50 | public function testBankEntryEntity() |
||
51 | { |
||
52 | $this->performEntityTest(\Picqer\Financials\Exact\BankEntry::class); |
||
53 | } |
||
54 | |||
55 | public function testBankEntryLineEntity() |
||
56 | { |
||
57 | $this->performEntityTest(\Picqer\Financials\Exact\BankEntryLine::class); |
||
58 | } |
||
59 | |||
60 | public function testBudgetEntity() |
||
61 | { |
||
62 | $this->performEntityTest(\Picqer\Financials\Exact\Budget::class); |
||
63 | } |
||
64 | |||
65 | public function testCashEntryEntity() |
||
66 | { |
||
67 | $this->performEntityTest(\Picqer\Financials\Exact\CashEntry::class); |
||
68 | } |
||
69 | |||
70 | public function testCashEntryLineEntity() |
||
71 | { |
||
72 | $this->performEntityTest(\Picqer\Financials\Exact\CashEntryLine::class); |
||
73 | } |
||
74 | |||
75 | public function testContactEntity() |
||
76 | { |
||
77 | $this->performEntityTest(\Picqer\Financials\Exact\Contact::class); |
||
78 | } |
||
79 | |||
80 | public function testCostcenterEntity() |
||
83 | } |
||
84 | |||
85 | public function testCostunitEntity() |
||
86 | { |
||
87 | $this->performEntityTest(\Picqer\Financials\Exact\Costunit::class); |
||
88 | } |
||
89 | |||
90 | public function testDirectDebitMandateEntity() |
||
93 | } |
||
94 | |||
95 | public function testDivisionEntity() |
||
98 | } |
||
99 | |||
100 | public function testSystemDivisionEntity() |
||
101 | { |
||
102 | $this->performEntityTest(\Picqer\Financials\Exact\SystemDivision::class); |
||
103 | } |
||
104 | |||
105 | public function testDocumentEntity() |
||
106 | { |
||
108 | } |
||
109 | |||
110 | public function testDocumentAttachmentEntity() |
||
117 | } |
||
118 | |||
119 | public function testDocumentCategoryEntity() |
||
120 | { |
||
121 | $this->performEntityTest(\Picqer\Financials\Exact\DocumentCategory::class); |
||
122 | } |
||
123 | |||
124 | public function testDocumentTypeEntity() |
||
125 | { |
||
126 | $this->performEntityTest(\Picqer\Financials\Exact\DocumentType::class); |
||
127 | } |
||
128 | |||
129 | public function testEmployeeEntity() |
||
132 | } |
||
133 | |||
134 | public function testExchangeRateEntity() |
||
135 | { |
||
136 | $this->performEntityTest(\Picqer\Financials\Exact\ExchangeRate::class); |
||
137 | } |
||
138 | |||
139 | public function testGeneralJournalEntity() |
||
140 | { |
||
141 | $this->performEntityTest(\Picqer\Financials\Exact\GeneralJournalEntry::class); |
||
142 | } |
||
143 | |||
144 | public function testGeneralJournalEntryLineEntity() |
||
145 | { |
||
146 | $this->performEntityTest(\Picqer\Financials\Exact\GeneralJournalEntryLine::class); |
||
147 | } |
||
148 | |||
149 | public function testGLAccountEntity() |
||
150 | { |
||
151 | $this->performEntityTest(\Picqer\Financials\Exact\GLAccount::class); |
||
152 | } |
||
153 | |||
154 | public function testGLTransactionTypeEntity() |
||
155 | { |
||
156 | $this->performEntityTest(\Picqer\Financials\Exact\GLTransactionType::class); |
||
157 | } |
||
158 | |||
159 | public function testInvoiceSalesOrdersEntity() |
||
160 | { |
||
161 | $this->performEntityTest(\Picqer\Financials\Exact\InvoiceSalesOrder::class); |
||
162 | } |
||
163 | |||
164 | public function testItemEntity() |
||
165 | { |
||
166 | $this->performEntityTest(\Picqer\Financials\Exact\Item::class); |
||
167 | $item = new \Picqer\Financials\Exact\Item(new Connection()); |
||
168 | $item->PictureUrl = 'http://www.example.org/index.html?id=123'; |
||
169 | |||
170 | $this->assertSame('http://www.example.org/index.html?id=123', $item->getDownloadUrl()); |
||
171 | } |
||
172 | |||
173 | public function testItemExtraField() |
||
174 | { |
||
175 | $this->performEntityTest(\Picqer\Financials\Exact\ItemExtraField::class); |
||
176 | } |
||
177 | |||
178 | public function testItemGroupEntity() |
||
179 | { |
||
180 | $this->performEntityTest(\Picqer\Financials\Exact\ItemGroup::class); |
||
181 | } |
||
182 | |||
183 | public function testItemWarehouseEntity() |
||
184 | { |
||
185 | $this->performEntityTest(\Picqer\Financials\Exact\ItemWarehouse::class); |
||
186 | } |
||
187 | |||
188 | public function testJournalEntity() |
||
189 | { |
||
190 | $this->performEntityTest(\Picqer\Financials\Exact\Journal::class); |
||
191 | } |
||
192 | |||
193 | public function testLayoutEntity() |
||
194 | { |
||
195 | $this->performEntityTest(\Picqer\Financials\Exact\Layout::class); |
||
196 | } |
||
197 | |||
198 | public function testMailMessageEntity() |
||
199 | { |
||
200 | $this->performEntityTest(\Picqer\Financials\Exact\MailMessage::class); |
||
201 | } |
||
202 | |||
203 | public function testMailMessageAttachmentEntity() |
||
204 | { |
||
205 | $this->performEntityTest(\Picqer\Financials\Exact\MailMessageAttachment::class); |
||
206 | } |
||
207 | |||
208 | public function testMeEntity() |
||
209 | { |
||
210 | $this->performEntityTest(\Picqer\Financials\Exact\Me::class); |
||
211 | } |
||
212 | |||
213 | public function testOutstandingInvoicesOverviewEntity() |
||
214 | { |
||
215 | $this->performEntityTest(\Picqer\Financials\Exact\OutstandingInvoicesOverview::class); |
||
216 | } |
||
217 | |||
218 | public function testPayablesListEntity() |
||
219 | { |
||
220 | $this->performEntityTest(\Picqer\Financials\Exact\PayablesList::class); |
||
221 | } |
||
222 | |||
223 | public function testPaymentConditionEntity() |
||
224 | { |
||
225 | $this->performEntityTest(\Picqer\Financials\Exact\PaymentCondition::class); |
||
226 | } |
||
227 | |||
228 | public function testPrintedSalesInvoiceEntity() |
||
229 | { |
||
230 | $this->performEntityTest(\Picqer\Financials\Exact\PrintedSalesInvoice::class); |
||
231 | } |
||
232 | |||
233 | public function testProfitLossOverviewEntity() |
||
234 | { |
||
235 | $this->performEntityTest(\Picqer\Financials\Exact\ProfitLossOverview::class); |
||
236 | } |
||
237 | |||
238 | public function testPurchaseEntryEntity() |
||
239 | { |
||
240 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseEntry::class); |
||
241 | } |
||
242 | |||
243 | public function testPurchaseEntryLineEntity() |
||
244 | { |
||
245 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseEntryLine::class); |
||
246 | } |
||
247 | |||
248 | public function testPurchaseOrderEntity() |
||
249 | { |
||
250 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseOrder::class); |
||
251 | } |
||
252 | |||
253 | public function testPurchaseOrderLineEntity() |
||
254 | { |
||
255 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseOrderLine::class); |
||
256 | } |
||
257 | |||
258 | public function testQuotationEntity() |
||
259 | { |
||
260 | $this->performEntityTest(\Picqer\Financials\Exact\Quotation::class); |
||
261 | } |
||
262 | |||
263 | public function testQuotationLineEntity() |
||
264 | { |
||
265 | $this->performEntityTest(\Picqer\Financials\Exact\QuotationLine::class); |
||
266 | } |
||
267 | |||
268 | public function testReceivableListEntity() |
||
269 | { |
||
270 | $this->performEntityTest(\Picqer\Financials\Exact\ReceivableList::class); |
||
271 | } |
||
272 | |||
273 | public function testReportingBalanceEntity() |
||
274 | { |
||
275 | $this->performEntityTest(\Picqer\Financials\Exact\ReportingBalance::class); |
||
276 | } |
||
277 | |||
278 | public function testSalesEntryEntity() |
||
279 | { |
||
280 | $this->performEntityTest(\Picqer\Financials\Exact\SalesEntry::class); |
||
281 | } |
||
282 | |||
283 | public function testSalesEntryLineEntity() |
||
284 | { |
||
285 | $this->performEntityTest(\Picqer\Financials\Exact\SalesEntryLine::class); |
||
286 | } |
||
287 | |||
288 | public function testSalesInvoiceEntity() |
||
289 | { |
||
290 | $this->performEntityTest(\Picqer\Financials\Exact\SalesInvoice::class); |
||
291 | } |
||
292 | |||
293 | public function testSalesInvoiceLineEntity() |
||
294 | { |
||
295 | $this->performEntityTest(\Picqer\Financials\Exact\SalesInvoiceLine::class); |
||
296 | } |
||
297 | |||
298 | public function testSalesItemPriceEntity() |
||
299 | { |
||
300 | $this->performEntityTest(\Picqer\Financials\Exact\SalesItemPrice::class); |
||
301 | } |
||
302 | |||
303 | public function testSalesOrderEntity() |
||
304 | { |
||
305 | $this->performEntityTest(\Picqer\Financials\Exact\SalesOrder::class); |
||
306 | } |
||
307 | |||
308 | public function testSalesOrderLineEntity() |
||
309 | { |
||
310 | $this->performEntityTest(\Picqer\Financials\Exact\SalesOrderLine::class); |
||
311 | } |
||
312 | |||
313 | public function testStockPositionEntity() |
||
314 | { |
||
315 | $this->performEntityTest(\Picqer\Financials\Exact\StockPosition::class); |
||
316 | } |
||
317 | |||
318 | public function testSubscriptionEntity() |
||
319 | { |
||
320 | $this->performEntityTest(\Picqer\Financials\Exact\Subscription::class); |
||
321 | } |
||
322 | |||
323 | public function testSubscriptionLineEntity() |
||
324 | { |
||
325 | $this->performEntityTest(\Picqer\Financials\Exact\SubscriptionLine::class); |
||
326 | } |
||
327 | |||
328 | public function testSubscriptionTypeEntity() |
||
329 | { |
||
330 | $this->performEntityTest(\Picqer\Financials\Exact\SubscriptionType::class); |
||
331 | } |
||
332 | |||
333 | public function testTransactionEntity() |
||
334 | { |
||
335 | $this->performEntityTest(\Picqer\Financials\Exact\Transaction::class); |
||
336 | } |
||
337 | |||
338 | public function testTransactionLineEntity() |
||
339 | { |
||
340 | $this->performEntityTest(\Picqer\Financials\Exact\TransactionLine::class); |
||
341 | } |
||
342 | |||
343 | public function testUnitsEntity() |
||
344 | { |
||
345 | $this->performEntityTest(\Picqer\Financials\Exact\Units::class); |
||
346 | } |
||
347 | |||
348 | public function testVatcodeEntity() |
||
349 | { |
||
350 | $this->performEntityTest(\Picqer\Financials\Exact\VatCode::class); |
||
351 | } |
||
352 | |||
353 | public function testWebhookSubscriptionEntity() |
||
354 | { |
||
355 | $this->performEntityTest(\Picqer\Financials\Exact\WebhookSubscription::class); |
||
356 | } |
||
357 | |||
358 | public function testStockCountEntity() |
||
359 | { |
||
360 | $this->performEntityTest(\Picqer\Financials\Exact\StockCount::class); |
||
361 | } |
||
362 | |||
363 | public function testStockCountLineEntity() |
||
364 | { |
||
365 | $this->performEntityTest(\Picqer\Financials\Exact\StockCountLine::class); |
||
366 | } |
||
367 | |||
368 | public function testWarehouseEntity() |
||
369 | { |
||
370 | $this->performEntityTest(\Picqer\Financials\Exact\Warehouse::class); |
||
371 | } |
||
372 | |||
373 | public function testStorageLocationEntity() |
||
374 | { |
||
375 | $this->performEntityTest(\Picqer\Financials\Exact\StorageLocation::class); |
||
376 | } |
||
377 | |||
378 | public function testGoodsDeliveryEntity() |
||
379 | { |
||
380 | $this->performEntityTest(\Picqer\Financials\Exact\GoodsDelivery::class); |
||
381 | } |
||
382 | |||
383 | public function testGoodsDeliveryLineEntity() |
||
384 | { |
||
385 | $this->performEntityTest(\Picqer\Financials\Exact\GoodsDeliveryLine::class); |
||
386 | } |
||
387 | |||
388 | public function testSalesOrderIDEntity() |
||
389 | { |
||
390 | $this->performEntityTest(\Picqer\Financials\Exact\SalesOrderID::class); |
||
391 | } |
||
392 | |||
393 | public function testItemWarehousePlanningDetails() |
||
394 | { |
||
395 | $this->performEntityTest(\Picqer\Financials\Exact\ItemWarehousePlanningDetails::class); |
||
396 | } |
||
397 | |||
398 | public function testSalesShippingMethods() |
||
399 | { |
||
400 | $this->performEntityTest(\Picqer\Financials\Exact\SalesShippingMethods::class); |
||
401 | } |
||
402 | |||
403 | public function testInvoiceTerm() |
||
404 | { |
||
405 | $this->performEntityTest(\Picqer\Financials\Exact\InvoiceTerm::class); |
||
406 | } |
||
407 | |||
408 | public function testBillOfMaterialVersion() |
||
409 | { |
||
410 | $this->performEntityTest(\Picqer\Financials\Exact\BillOfMaterialVersion::class); |
||
411 | } |
||
412 | |||
413 | public function testBillOfMaterialMaterial() |
||
414 | { |
||
415 | $this->performEntityTest(\Picqer\Financials\Exact\BillOfMaterialMaterial::class); |
||
416 | } |
||
417 | |||
418 | public function testProject() |
||
419 | { |
||
420 | $this->performEntityTest(\Picqer\Financials\Exact\Project::class); |
||
421 | } |
||
422 | |||
423 | public function testProjectWBSByProject() |
||
424 | { |
||
425 | $this->performEntityTest(\Picqer\Financials\Exact\ProjectWBSByProject::class); |
||
426 | } |
||
427 | |||
428 | public function testShopOrder() |
||
429 | { |
||
430 | $this->performEntityTest(\Picqer\Financials\Exact\ShopOrder::class); |
||
431 | } |
||
432 | |||
433 | public function testTimeTransactionEntity() |
||
436 | } |
||
437 | |||
438 | public function testUser() |
||
439 | { |
||
440 | $this->performEntityTest(\Picqer\Financials\Exact\User::class); |
||
441 | } |
||
442 | |||
443 | public function testShopOrderMaterialPlan() |
||
444 | { |
||
445 | $this->performEntityTest(\Picqer\Financials\Exact\ShopOrderMaterialPlan::class); |
||
446 | } |
||
447 | |||
448 | public function testShopOrderRoutingStepPlan() |
||
449 | { |
||
450 | $this->performEntityTest(\Picqer\Financials\Exact\ShopOrderRoutingStepPlan::class); |
||
451 | } |
||
452 | |||
453 | public function testOperation() |
||
454 | { |
||
455 | $this->performEntityTest(\Picqer\Financials\Exact\Operation::class); |
||
456 | } |
||
457 | |||
458 | public function testOperationResource() |
||
459 | { |
||
460 | $this->performEntityTest(\Picqer\Financials\Exact\OperationResource::class); |
||
461 | } |
||
462 | |||
463 | protected function performEntityTest($entityName) |
||
464 | { |
||
465 | $reflectionClass = new ReflectionClass($entityName); |
||
466 | |||
467 | $this->assertTrue($reflectionClass->isInstantiable()); |
||
468 | $this->assertTrue($reflectionClass->hasProperty('fillable')); |
||
469 | $this->assertTrue($reflectionClass->hasProperty('url')); |
||
470 | $this->assertEquals('Picqer\Financials\Exact', $reflectionClass->getNamespaceName()); |
||
471 | $this->assertEquals('Picqer\Financials\Exact\Model', $reflectionClass->getParentClass()->getName()); |
||
472 | } |
||
473 | |||
474 | } |
||
475 |