| Total Complexity | 69 |
| Total Lines | 352 |
| Duplicated Lines | 0 % |
| Changes | 12 | ||
| Bugs | 1 | Features | 4 |
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() |
||
| 19 | { |
||
| 20 | $this->performEntityTest(\Picqer\Financials\Exact\AccountClassification::class); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function testAccountItemEntity() |
||
| 24 | { |
||
| 25 | $this->performEntityTest(\Picqer\Financials\Exact\AccountItem::class); |
||
| 26 | } |
||
| 27 | |||
| 28 | public function testAddressEntity() |
||
| 29 | { |
||
| 30 | $this->performEntityTest(\Picqer\Financials\Exact\Address::class); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function testBankAccountEntity() |
||
| 34 | { |
||
| 35 | $this->performEntityTest(\Picqer\Financials\Exact\BankAccount::class); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function testBankEntryEntity() |
||
| 39 | { |
||
| 40 | $this->performEntityTest(\Picqer\Financials\Exact\BankEntry::class); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function testBankEntryLineEntity() |
||
| 44 | { |
||
| 45 | $this->performEntityTest(\Picqer\Financials\Exact\BankEntryLine::class); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function testBudgetEntity() |
||
| 49 | { |
||
| 50 | $this->performEntityTest(\Picqer\Financials\Exact\Budget::class); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function testCashEntryEntity() |
||
| 54 | { |
||
| 55 | $this->performEntityTest(\Picqer\Financials\Exact\CashEntry::class); |
||
| 56 | } |
||
| 57 | |||
| 58 | public function testCashEntryLineEntity() |
||
| 59 | { |
||
| 60 | $this->performEntityTest(\Picqer\Financials\Exact\CashEntryLine::class); |
||
| 61 | } |
||
| 62 | |||
| 63 | public function testContactEntity() |
||
| 64 | { |
||
| 65 | $this->performEntityTest(\Picqer\Financials\Exact\Contact::class); |
||
| 66 | } |
||
| 67 | |||
| 68 | public function testCostcenterEntity() |
||
| 69 | { |
||
| 70 | $this->performEntityTest(\Picqer\Financials\Exact\Costcenter::class); |
||
| 71 | } |
||
| 72 | |||
| 73 | public function testCostunitEntity() |
||
| 74 | { |
||
| 75 | $this->performEntityTest(\Picqer\Financials\Exact\Costunit::class); |
||
| 76 | } |
||
| 77 | |||
| 78 | public function testDirectDebitMandateEntity() |
||
| 79 | { |
||
| 80 | $this->performEntityTest(\Picqer\Financials\Exact\DirectDebitMandate::class); |
||
| 81 | } |
||
| 82 | |||
| 83 | public function testDivisionEntity() |
||
| 84 | { |
||
| 85 | $this->performEntityTest(\Picqer\Financials\Exact\Division::class); |
||
| 86 | } |
||
| 87 | |||
| 88 | public function testSystemDivisionEntity() |
||
| 89 | { |
||
| 90 | $this->performEntityTest(\Picqer\Financials\Exact\SystemDivision::class); |
||
| 91 | } |
||
| 92 | |||
| 93 | public function testDocumentEntity() |
||
| 94 | { |
||
| 95 | $this->performEntityTest(\Picqer\Financials\Exact\Document::class); |
||
| 96 | } |
||
| 97 | |||
| 98 | public function testDocumentAttachmentEntity() |
||
| 99 | { |
||
| 100 | $this->performEntityTest(\Picqer\Financials\Exact\DocumentAttachment::class); |
||
| 101 | } |
||
| 102 | |||
| 103 | public function testGeneralJournalEntity() |
||
| 104 | { |
||
| 105 | $this->performEntityTest(\Picqer\Financials\Exact\GeneralJournalEntry::class); |
||
| 106 | } |
||
| 107 | |||
| 108 | public function testGeneralJournalEntryLineEntity() |
||
| 109 | { |
||
| 110 | $this->performEntityTest(\Picqer\Financials\Exact\GeneralJournalEntryLine::class); |
||
| 111 | } |
||
| 112 | |||
| 113 | public function testGLAccountEntity() |
||
| 114 | { |
||
| 115 | $this->performEntityTest(\Picqer\Financials\Exact\GLAccount::class); |
||
| 116 | } |
||
| 117 | |||
| 118 | public function testInvoiceSalesOrdersEntity() |
||
| 119 | { |
||
| 120 | $this->performEntityTest(\Picqer\Financials\Exact\InvoiceSalesOrder::class); |
||
| 121 | } |
||
| 122 | |||
| 123 | public function testItemEntity() |
||
| 124 | { |
||
| 125 | $this->performEntityTest(\Picqer\Financials\Exact\Item::class); |
||
| 126 | } |
||
| 127 | |||
| 128 | public function testItemGroupEntity() |
||
| 129 | { |
||
| 130 | $this->performEntityTest(\Picqer\Financials\Exact\ItemGroup::class); |
||
| 131 | } |
||
| 132 | |||
| 133 | public function testItemWarehouseEntity() |
||
| 134 | { |
||
| 135 | $this->performEntityTest(\Picqer\Financials\Exact\ItemWarehouse::class); |
||
| 136 | } |
||
| 137 | |||
| 138 | public function testJournalEntity() |
||
| 139 | { |
||
| 140 | $this->performEntityTest(\Picqer\Financials\Exact\Journal::class); |
||
| 141 | } |
||
| 142 | |||
| 143 | public function testLayoutEntity() |
||
| 144 | { |
||
| 145 | $this->performEntityTest(\Picqer\Financials\Exact\Layout::class); |
||
| 146 | } |
||
| 147 | |||
| 148 | public function testMailMessageEntity() |
||
| 149 | { |
||
| 150 | $this->performEntityTest(\Picqer\Financials\Exact\MailMessage::class); |
||
| 151 | } |
||
| 152 | |||
| 153 | public function testMailMessageAttachmentEntity() |
||
| 154 | { |
||
| 155 | $this->performEntityTest(\Picqer\Financials\Exact\MailMessageAttachment::class); |
||
| 156 | } |
||
| 157 | |||
| 158 | public function testMeEntity() |
||
| 159 | { |
||
| 160 | $this->performEntityTest(\Picqer\Financials\Exact\Me::class); |
||
| 161 | } |
||
| 162 | |||
| 163 | public function testPayablesListEntity() |
||
| 164 | { |
||
| 165 | $this->performEntityTest(\Picqer\Financials\Exact\PayablesList::class); |
||
| 166 | } |
||
| 167 | |||
| 168 | public function testPaymentConditionEntity() |
||
| 169 | { |
||
| 170 | $this->performEntityTest(\Picqer\Financials\Exact\PaymentCondition::class); |
||
| 171 | } |
||
| 172 | |||
| 173 | public function testPrintedSalesInvoiceEntity() |
||
| 174 | { |
||
| 175 | $this->performEntityTest(\Picqer\Financials\Exact\PrintedSalesInvoice::class); |
||
| 176 | } |
||
| 177 | |||
| 178 | public function testProfitLossOverviewEntity() |
||
| 179 | { |
||
| 180 | $this->performEntityTest(\Picqer\Financials\Exact\ProfitLossOverview::class); |
||
| 181 | } |
||
| 182 | |||
| 183 | public function testPurchaseEntryEntity() |
||
| 184 | { |
||
| 185 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseEntry::class); |
||
| 186 | } |
||
| 187 | |||
| 188 | public function testPurchaseEntryLineEntity() |
||
| 189 | { |
||
| 190 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseEntryLine::class); |
||
| 191 | } |
||
| 192 | |||
| 193 | public function testPurchaseOrderEntity() |
||
| 194 | { |
||
| 195 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseOrder::class); |
||
| 196 | } |
||
| 197 | |||
| 198 | public function testPurchaseOrderLineEntity() |
||
| 199 | { |
||
| 200 | $this->performEntityTest(\Picqer\Financials\Exact\PurchaseOrderLine::class); |
||
| 201 | } |
||
| 202 | |||
| 203 | public function testQuotationEntity() |
||
| 204 | { |
||
| 205 | $this->performEntityTest(\Picqer\Financials\Exact\Quotation::class); |
||
| 206 | } |
||
| 207 | |||
| 208 | public function testQuotationLineEntity() |
||
| 209 | { |
||
| 210 | $this->performEntityTest(\Picqer\Financials\Exact\QuotationLine::class); |
||
| 211 | } |
||
| 212 | |||
| 213 | public function testReceivableListEntity() |
||
| 214 | { |
||
| 215 | $this->performEntityTest(\Picqer\Financials\Exact\ReceivableList::class); |
||
| 216 | } |
||
| 217 | |||
| 218 | public function testReportingBalanceEntity() |
||
| 219 | { |
||
| 220 | $this->performEntityTest(\Picqer\Financials\Exact\ReportingBalance::class); |
||
| 221 | } |
||
| 222 | |||
| 223 | public function testSalesEntryEntity() |
||
| 224 | { |
||
| 225 | $this->performEntityTest(\Picqer\Financials\Exact\SalesEntry::class); |
||
| 226 | } |
||
| 227 | |||
| 228 | public function testSalesEntryLineEntity() |
||
| 229 | { |
||
| 230 | $this->performEntityTest(\Picqer\Financials\Exact\SalesEntryLine::class); |
||
| 231 | } |
||
| 232 | |||
| 233 | public function testSalesInvoiceEntity() |
||
| 234 | { |
||
| 235 | $this->performEntityTest(\Picqer\Financials\Exact\SalesInvoice::class); |
||
| 236 | } |
||
| 237 | |||
| 238 | public function testSalesInvoiceLineEntity() |
||
| 239 | { |
||
| 240 | $this->performEntityTest(\Picqer\Financials\Exact\SalesInvoiceLine::class); |
||
| 241 | } |
||
| 242 | |||
| 243 | public function testSalesItemPriceEntity() |
||
| 244 | { |
||
| 245 | $this->performEntityTest(\Picqer\Financials\Exact\SalesItemPrice::class); |
||
| 246 | } |
||
| 247 | |||
| 248 | public function testSalesOrderEntity() |
||
| 249 | { |
||
| 250 | $this->performEntityTest(\Picqer\Financials\Exact\SalesOrder::class); |
||
| 251 | } |
||
| 252 | |||
| 253 | public function testSalesOrderLineEntity() |
||
| 254 | { |
||
| 255 | $this->performEntityTest(\Picqer\Financials\Exact\SalesOrderLine::class); |
||
| 256 | } |
||
| 257 | |||
| 258 | public function testStockPositionEntity() |
||
| 259 | { |
||
| 260 | $this->performEntityTest(\Picqer\Financials\Exact\StockPosition::class); |
||
| 261 | } |
||
| 262 | |||
| 263 | public function testSubscriptionEntity() |
||
| 264 | { |
||
| 265 | $this->performEntityTest(\Picqer\Financials\Exact\Subscription::class); |
||
| 266 | } |
||
| 267 | |||
| 268 | public function testSubscriptionLineEntity() |
||
| 269 | { |
||
| 270 | $this->performEntityTest(\Picqer\Financials\Exact\SubscriptionLine::class); |
||
| 271 | } |
||
| 272 | |||
| 273 | public function testSubscriptionTypeEntity() |
||
| 274 | { |
||
| 275 | $this->performEntityTest(\Picqer\Financials\Exact\SubscriptionType::class); |
||
| 276 | } |
||
| 277 | |||
| 278 | public function testTransactionEntity() |
||
| 279 | { |
||
| 280 | $this->performEntityTest(\Picqer\Financials\Exact\Transaction::class); |
||
| 281 | } |
||
| 282 | |||
| 283 | public function testTransactionLineEntity() |
||
| 284 | { |
||
| 285 | $this->performEntityTest(\Picqer\Financials\Exact\TransactionLine::class); |
||
| 286 | } |
||
| 287 | |||
| 288 | public function testUnitsEntity() |
||
| 291 | } |
||
| 292 | |||
| 293 | public function testVatcodeEntity() |
||
| 294 | { |
||
| 295 | $this->performEntityTest(\Picqer\Financials\Exact\VatCode::class); |
||
| 296 | } |
||
| 297 | |||
| 298 | public function testWebhookSubscriptionEntity() |
||
| 299 | { |
||
| 300 | $this->performEntityTest(\Picqer\Financials\Exact\WebhookSubscription::class); |
||
| 301 | } |
||
| 302 | |||
| 303 | public function testStockCountEntity() |
||
| 304 | { |
||
| 305 | $this->performEntityTest(\Picqer\Financials\Exact\StockCount::class); |
||
| 306 | } |
||
| 307 | |||
| 308 | public function testStockCountLineEntity() |
||
| 309 | { |
||
| 310 | $this->performEntityTest(\Picqer\Financials\Exact\StockCountLine::class); |
||
| 311 | } |
||
| 312 | |||
| 313 | public function testWarehouseEntity() |
||
| 314 | { |
||
| 315 | $this->performEntityTest(\Picqer\Financials\Exact\Warehouse::class); |
||
| 316 | } |
||
| 317 | |||
| 318 | public function testStorageLocationEntity() |
||
| 319 | { |
||
| 320 | $this->performEntityTest(\Picqer\Financials\Exact\StorageLocation::class); |
||
| 321 | } |
||
| 322 | |||
| 323 | public function testGoodsDeliveryEntity() |
||
| 324 | { |
||
| 325 | $this->performEntityTest(\Picqer\Financials\Exact\GoodsDelivery::class); |
||
| 326 | } |
||
| 327 | |||
| 328 | public function testGoodsDeliveryLineEntity() |
||
| 329 | { |
||
| 330 | $this->performEntityTest(\Picqer\Financials\Exact\GoodsDeliveryLine::class); |
||
| 331 | } |
||
| 332 | |||
| 333 | public function testSalesOrderIDEntity() |
||
| 336 | } |
||
| 337 | |||
| 338 | public function testItemWarehousePlanningDetails() |
||
| 339 | { |
||
| 340 | $this->performEntityTest(\Picqer\Financials\Exact\ItemWarehousePlanningDetails::class); |
||
| 341 | } |
||
| 342 | |||
| 343 | public function testSalesShippingMethods() |
||
| 344 | { |
||
| 345 | $this->performEntityTest(\Picqer\Financials\Exact\SalesShippingMethods::class); |
||
| 346 | } |
||
| 347 | |||
| 348 | public function testSalesPriceListDetails() |
||
| 349 | { |
||
| 350 | $this->performEntityTest(\Picqer\Financials\Exact\SalesPriceListDetails::class); |
||
| 351 | } |
||
| 352 | |||
| 353 | protected function performEntityTest($entityName) |
||
| 354 | { |
||
| 355 | $reflectionClass = new ReflectionClass($entityName); |
||
| 356 | |||
| 357 | $this->assertTrue($reflectionClass->isInstantiable()); |
||
| 358 | $this->assertTrue($reflectionClass->hasProperty('fillable')); |
||
| 359 | $this->assertTrue($reflectionClass->hasProperty('url')); |
||
| 360 | $this->assertEquals('Picqer\Financials\Exact', $reflectionClass->getNamespaceName()); |
||
| 361 | $this->assertEquals('Picqer\Financials\Exact\Model', $reflectionClass->getParentClass()->getName()); |
||
| 362 | } |
||
| 363 | |||
| 364 | } |
||
| 365 |