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