Complex classes like FlexiBeeRWTest 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 FlexiBeeRWTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
10 | class FlexiBeeRWTest extends FlexiBeeROTest |
||
11 | { |
||
12 | /** |
||
13 | * Poznámka vkládaná do záznamů vytvářených během testů |
||
14 | * @var string |
||
15 | */ |
||
16 | public $poznam = 'Generováno UnitTestem PHP Knihovny https://github.com/Spoje-NET/FlexiPeeHP'; |
||
17 | |||
18 | /** |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | public $insertableData = []; |
||
23 | |||
24 | /** |
||
25 | * @var FlexiBeeRW |
||
26 | */ |
||
27 | protected $object; |
||
28 | |||
29 | /** |
||
30 | * Gives You data able to insert into current evidence |
||
31 | * |
||
32 | * @param string $code custom record code |
||
33 | * |
||
34 | * @return array |
||
35 | */ |
||
36 | public function getDataForInsert($code = 'UnitTest') |
||
65 | |||
66 | /** |
||
67 | * Sets up the fixture, for example, opens a network connection. |
||
68 | * This method is called before a test is executed. |
||
69 | * @covers FlexiPeeHP\FlexiBeeRW::__construct |
||
70 | */ |
||
71 | protected function setUp() |
||
76 | |||
77 | /** |
||
78 | * Tears down the fixture, for example, closes a network connection. |
||
79 | * This method is called after a test is executed. |
||
80 | */ |
||
81 | protected function tearDown() |
||
85 | |||
86 | /** |
||
87 | * @covers FlexiPeeHP\FlexiBeeRW::performAction |
||
88 | * @expectedException \Exception |
||
89 | */ |
||
90 | public function testPerformAction() |
||
106 | |||
107 | /** |
||
108 | * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDate |
||
109 | */ |
||
110 | public function testTimestampToFlexiDate() |
||
116 | |||
117 | /** |
||
118 | * @covers FlexiPeeHP\FlexiBeeRW::timestampToFlexiDateTime |
||
119 | */ |
||
120 | public function testTimestampToFlexiDateTime() |
||
127 | |||
128 | /** |
||
129 | * @covers FlexiPeeHP\FlexiBeeRW::objectToID |
||
130 | */ |
||
131 | public function testObjectToID() |
||
138 | |||
139 | /** |
||
140 | * @covers FlexiPeeHP\FlexiBeeRW::getRecordID |
||
141 | */ |
||
142 | public function testGetRecordID() |
||
151 | |||
152 | /** |
||
153 | * @covers FlexiPeeHP\FlexiBeeRW::controlMandatoryColumns |
||
154 | */ |
||
155 | public function testControlMandatoryColumns() |
||
159 | |||
160 | /** |
||
161 | * @covers FlexiPeeHP\FlexiBeeRW::controlReadOnlyColumns |
||
162 | */ |
||
163 | public function testControlReadOnlyColumns() |
||
167 | |||
168 | /** |
||
169 | * @covers FlexiPeeHP\FlexiBeeRW::addArrayToBranch |
||
170 | */ |
||
171 | public function testAddArrayToBranch() |
||
175 | |||
176 | /** |
||
177 | * @covers FlexiPeeHP\FlexiBeeRW::addObjectToBranch |
||
178 | */ |
||
179 | public function testAddObjectToBranch() |
||
183 | |||
184 | /** |
||
185 | * @covers FlexiPeeHP\FlexiBeeRW::vazbaAdd |
||
186 | */ |
||
187 | public function testVazbaAdd() |
||
191 | |||
192 | /** |
||
193 | * @covers FlexiPeeHP\FlexiBeeRW::vazbaDel |
||
194 | */ |
||
195 | public function testVazbaDel() |
||
199 | |||
200 | /** |
||
201 | * @covers FlexiPeeHP\FlexiBeeRW::getJsonizedData |
||
202 | */ |
||
203 | public function testGetJsonizedData() |
||
209 | |||
210 | /** |
||
211 | * @covers FlexiPeeHP\FlexiBeeRW::refresh |
||
212 | */ |
||
213 | public function testRefresh() |
||
218 | |||
219 | /** |
||
220 | * @covers FlexiPeeHP\FlexiBeeRW::insertToFlexiBee |
||
221 | */ |
||
222 | public function testInsertToFlexiBee() |
||
226 | |||
227 | /** |
||
228 | * @covers FlexiPeeHP\FlexiBeeRW::parseResponse |
||
229 | */ |
||
230 | public function testParseResponse() |
||
285 | |||
286 | /** |
||
287 | * @covers FlexiPeeHP\FlexiBeeRW::assignResultIDs |
||
288 | */ |
||
289 | public function testAssignResultIDs() |
||
310 | |||
311 | /** |
||
312 | * @covers FlexiPeeHP\FlexiBeeRW::extractResultIDs |
||
313 | */ |
||
314 | public function testExtractResultIDs() |
||
355 | |||
356 | /** |
||
357 | * @covers FlexiPeeHP\FlexiBeeRW::getLastInsertedId |
||
358 | */ |
||
359 | public function testGetLastInsertedId() |
||
363 | |||
364 | /** |
||
365 | * @covers FlexiPeeHP\FlexiBeeRW::deleteFromFlexiBee |
||
366 | */ |
||
367 | public function testDeleteFromFlexiBee() |
||
371 | |||
372 | /** |
||
373 | * @covers FlexiPeeHP\FlexiBeeRW::takeData |
||
374 | */ |
||
375 | public function testTakeData() |
||
379 | |||
380 | /** |
||
381 | * @after |
||
382 | * @covers FlexiPeeHP\FlexiBeeRW::getDataForJSON |
||
383 | */ |
||
384 | public function testGetDataForJSON() |
||
389 | |||
390 | /** |
||
391 | * @covers FlexiPeeHP\FlexiBeeRW::addExternalID |
||
392 | */ |
||
393 | public function testAddExternalID() |
||
400 | |||
401 | /** |
||
402 | * @covers FlexiPeeHP\FlexiBeeRW::changeExternalID |
||
403 | */ |
||
404 | public function testChangeExternalID() |
||
409 | |||
410 | /** |
||
411 | * @covers FlexiPeeHP\FlexiBeeRW::sync |
||
412 | */ |
||
413 | public function testSync() |
||
422 | } |
||
423 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.