Passed
Push — master ( 573569...33f78f )
by Stephan
02:29
created

EntityTest   C

Complexity

Total Complexity 54

Size/Duplication

Total Lines 277
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 54
dl 0
loc 277
rs 6.8539
c 0
b 0
f 0

54 Methods

Rating   Name   Duplication   Size   Complexity  
A testUnitsEntity() 0 3 1
A testSalesEntryLineEntity() 0 3 1
A testReceivableListEntity() 0 3 1
A testReportingBalanceEntity() 0 3 1
A testSalesOrderEntity() 0 3 1
A testAccountClassificationEntity() 0 3 1
A testCostcenterEntity() 0 3 1
A testPayablesListEntity() 0 3 1
A testAccountEntity() 0 3 1
A testPrintedSalesInvoiceEntity() 0 3 1
A testItemWarehouseEntity() 0 3 1
A testJournalEntity() 0 3 1
A testBankEntryLineEntity() 0 3 1
A testProfitLossOverviewEntity() 0 3 1
A testPurchaseOrderEntity() 0 3 1
A testDirectDebitMandateEntity() 0 3 1
A testCashEntryEntity() 0 3 1
A testPurchaseEntryEntity() 0 3 1
A testSubscriptionEntity() 0 3 1
A testMeEntity() 0 3 1
A testTransactionEntity() 0 3 1
A testSalesEntryEntity() 0 3 1
A testVatcodeEntity() 0 3 1
A testSalesItemPriceEntity() 0 3 1
A testItemGroupEntity() 0 3 1
A testItemEntity() 0 3 1
A testPurchaseOrderLineEntity() 0 3 1
A testSalesOrderLineEntity() 0 3 1
A testDivisionEntity() 0 3 1
A testPurchaseEntryLineEntity() 0 3 1
A performEntityTest() 0 9 1
A testBankAccountEntity() 0 3 1
A testContactEntity() 0 3 1
A testGeneralJournalEntryLineEntity() 0 3 1
A testSubscriptionLineEntity() 0 3 1
A testAccountItemEntity() 0 3 1
A testGLAccountEntity() 0 3 1
A testTransactionLineEntity() 0 3 1
A testInvoiceSalesOrdersEntity() 0 3 1
A testCashEntryLineEntity() 0 3 1
A testMailMessageEntity() 0 3 1
A testMailMessageAttachmentEntity() 0 3 1
A testWebhookSubscriptionEntity() 0 3 1
A testSubscriptionTypeEntity() 0 3 1
A testBankEntryEntity() 0 3 1
A testStockPositionEntity() 0 3 1
A testDocumentEntity() 0 3 1
A testSalesInvoiceLineEntity() 0 3 1
A testGeneralJournalEntity() 0 3 1
A testAddressEntity() 0 3 1
A testPaymentConditionEntity() 0 3 1
A testSalesInvoiceEntity() 0 3 1
A testDocumentAttachmentEntity() 0 3 1
A testCostunitEntity() 0 3 1

How to fix   Complexity   

Complex Class

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
2
3
/**
4
 * Class EntityTest
5
 *
6
 * Tests all entities to ensure entities have no PHP parse errors and have
7
 * at least the properties we need to use the entity
8
 */
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()
18
    {
19
        $this->performEntityTest(\Picqer\Financials\Exact\AccountClassification::class);
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()
43
    {
44
        $this->performEntityTest(\Picqer\Financials\Exact\BankEntryLine::class);
45
    }
46
47
    public function testCashEntryEntity()
48
    {
49
        $this->performEntityTest(\Picqer\Financials\Exact\CashEntry::class);
50
    }
51
52
    public function testCashEntryLineEntity()
53
    {
54
        $this->performEntityTest(\Picqer\Financials\Exact\CashEntryLine::class);
55
    }
56
57
    public function testContactEntity()
58
    {
59
        $this->performEntityTest(\Picqer\Financials\Exact\Contact::class);
60
    }
61
62
    public function testCostcenterEntity()
63
    {
64
        $this->performEntityTest(\Picqer\Financials\Exact\Costcenter::class);
65
    }
66
67
    public function testCostunitEntity()
68
    {
69
        $this->performEntityTest(\Picqer\Financials\Exact\Costunit::class);
70
    }
71
72
    public function testDirectDebitMandateEntity()
73
    {
74
        $this->performEntityTest(\Picqer\Financials\Exact\DirectDebitMandate::class);
75
    }
76
77
    public function testDivisionEntity()
78
    {
79
        $this->performEntityTest(\Picqer\Financials\Exact\Division::class);
80
    }
81
82
    public function testDocumentEntity()
83
    {
84
        $this->performEntityTest(\Picqer\Financials\Exact\Document::class);
85
    }
86
87
    public function testDocumentAttachmentEntity()
88
    {
89
        $this->performEntityTest(\Picqer\Financials\Exact\DocumentAttachment::class);
90
    }
91
92
    public function testGeneralJournalEntity()
93
    {
94
        $this->performEntityTest(\Picqer\Financials\Exact\GeneralJournalEntry::class);
95
    }
96
97
    public function testGeneralJournalEntryLineEntity()
98
    {
99
        $this->performEntityTest(\Picqer\Financials\Exact\GeneralJournalEntryLine::class);
100
    }
101
102
    public function testGLAccountEntity()
103
    {
104
        $this->performEntityTest(\Picqer\Financials\Exact\GLAccount::class);
105
    }
106
107
    public function testInvoiceSalesOrdersEntity()
108
    {
109
        $this->performEntityTest(\Picqer\Financials\Exact\InvoiceSalesOrder::class);
110
    }
111
112
    public function testItemEntity()
113
    {
114
        $this->performEntityTest(\Picqer\Financials\Exact\Item::class);
115
    }
116
117
    public function testItemGroupEntity()
118
    {
119
        $this->performEntityTest(\Picqer\Financials\Exact\ItemGroup::class);
120
    }
121
122
    public function testItemWarehouseEntity()
123
    {
124
        $this->performEntityTest(\Picqer\Financials\Exact\ItemWarehouse::class);
125
    }
126
127
    public function testJournalEntity()
128
    {
129
        $this->performEntityTest(\Picqer\Financials\Exact\Journal::class);
130
    }
131
132
    public function testMailMessageEntity()
133
    {
134
        $this->performEntityTest(\Picqer\Financials\Exact\MailMessage::class);
135
    }
136
137
    public function testMailMessageAttachmentEntity()
138
    {
139
        $this->performEntityTest(\Picqer\Financials\Exact\MailMessageAttachment::class);
140
    }
141
142
    public function testMeEntity()
143
    {
144
        $this->performEntityTest(\Picqer\Financials\Exact\Me::class);
145
    }
146
147
    public function testPayablesListEntity()
148
    {
149
        $this->performEntityTest(\Picqer\Financials\Exact\PayablesList::class);
150
    }
151
152
    public function testPaymentConditionEntity()
153
    {
154
        $this->performEntityTest(\Picqer\Financials\Exact\PaymentCondition::class);
155
    }
156
157
    public function testPrintedSalesInvoiceEntity()
158
    {
159
        $this->performEntityTest(\Picqer\Financials\Exact\PrintedSalesInvoice::class);
160
    }
161
162
    public function testProfitLossOverviewEntity()
163
    {
164
        $this->performEntityTest(\Picqer\Financials\Exact\ProfitLossOverview::class);
165
    }
166
167
    public function testPurchaseEntryEntity()
168
    {
169
        $this->performEntityTest(\Picqer\Financials\Exact\PurchaseEntry::class);
170
    }
171
172
    public function testPurchaseEntryLineEntity()
173
    {
174
        $this->performEntityTest(\Picqer\Financials\Exact\PurchaseEntryLine::class);
175
    }
176
177
    public function testPurchaseOrderEntity()
178
    {
179
        $this->performEntityTest(\Picqer\Financials\Exact\PurchaseOrder::class);
180
    }
181
182
    public function testPurchaseOrderLineEntity()
183
    {
184
        $this->performEntityTest(\Picqer\Financials\Exact\PurchaseOrderLine::class);
185
    }
186
187
    public function testReceivableListEntity()
188
    {
189
        $this->performEntityTest(\Picqer\Financials\Exact\ReceivableList::class);
190
    }
191
192
    public function testReportingBalanceEntity()
193
    {
194
        $this->performEntityTest(\Picqer\Financials\Exact\ReportingBalance::class);
195
    }
196
197
    public function testSalesEntryEntity()
198
    {
199
        $this->performEntityTest(\Picqer\Financials\Exact\SalesEntry::class);
200
    }
201
202
    public function testSalesEntryLineEntity()
203
    {
204
        $this->performEntityTest(\Picqer\Financials\Exact\SalesEntryLine::class);
205
    }
206
207
    public function testSalesInvoiceEntity()
208
    {
209
        $this->performEntityTest(\Picqer\Financials\Exact\SalesInvoice::class);
210
    }
211
212
    public function testSalesInvoiceLineEntity()
213
    {
214
        $this->performEntityTest(\Picqer\Financials\Exact\SalesInvoiceLine::class);
215
    }
216
217
    public function testSalesItemPriceEntity()
218
    {
219
        $this->performEntityTest(\Picqer\Financials\Exact\SalesItemPrice::class);
220
    }
221
222
    public function testSalesOrderEntity()
223
    {
224
        $this->performEntityTest(\Picqer\Financials\Exact\SalesOrder::class);
225
    }
226
227
    public function testSalesOrderLineEntity()
228
    {
229
        $this->performEntityTest(\Picqer\Financials\Exact\SalesOrderLine::class);
230
    }
231
232
    public function testStockPositionEntity()
233
    {
234
        $this->performEntityTest(\Picqer\Financials\Exact\StockPosition::class);
235
    }
236
237
    public function testSubscriptionEntity()
238
    {
239
        $this->performEntityTest(\Picqer\Financials\Exact\Subscription::class);
240
    }
241
242
    public function testSubscriptionLineEntity()
243
    {
244
        $this->performEntityTest(\Picqer\Financials\Exact\SubscriptionLine::class);
245
    }
246
247
    public function testSubscriptionTypeEntity()
248
    {
249
        $this->performEntityTest(\Picqer\Financials\Exact\SubscriptionType::class);
250
    }
251
252
    public function testTransactionEntity()
253
    {
254
        $this->performEntityTest(\Picqer\Financials\Exact\Transaction::class);
255
    }
256
257
    public function testTransactionLineEntity()
258
    {
259
        $this->performEntityTest(\Picqer\Financials\Exact\TransactionLine::class);
260
    }
261
262
    public function testUnitsEntity()
263
    {
264
        $this->performEntityTest(\Picqer\Financials\Exact\Units::class);
265
    }
266
267
    public function testVatcodeEntity()
268
    {
269
        $this->performEntityTest(\Picqer\Financials\Exact\VatCode::class);
270
    }
271
272
    public function testWebhookSubscriptionEntity()
273
    {
274
        $this->performEntityTest(\Picqer\Financials\Exact\WebhookSubscription::class);
275
    }
276
277
    protected function performEntityTest($entityName)
278
    {
279
        $reflectionClass = new ReflectionClass($entityName);
280
281
        $this->assertTrue($reflectionClass->isInstantiable());
282
        $this->assertTrue($reflectionClass->hasProperty('fillable'));
283
        $this->assertTrue($reflectionClass->hasProperty('url'));
284
        $this->assertEquals('Picqer\Financials\Exact', $reflectionClass->getNamespaceName());
285
        $this->assertEquals('Picqer\Financials\Exact\Model', $reflectionClass->getParentClass()->getName());
286
    }
287
288
}