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