| Conditions | 1 |
| Paths | 1 |
| Total Lines | 70 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 27 | public function testPositionQuest() |
||
| 28 | { |
||
| 29 | $testcase = 'questinfo-position.txt'; |
||
| 30 | $config = [ |
||
| 31 | 'bot_quest' => __DIR__ . '/../testcases/' . $testcase, |
||
| 32 | ]; |
||
| 33 | |||
| 34 | $parser = new BotParser($config); |
||
| 35 | $db = $parser->getQuestData(); |
||
| 36 | |||
| 37 | // Title |
||
| 38 | $this->assertEquals('lay waste to the Towers of Ankh-Allor, wherein lies the terrible sorceror Croocq', $db['title']); |
||
| 39 | |||
| 40 | // Type |
||
| 41 | $this->assertEquals(2, $db['type']); |
||
| 42 | |||
| 43 | // Current stage |
||
| 44 | $this->assertEquals(1, $db['objective']); |
||
| 45 | |||
| 46 | // Number of stages |
||
| 47 | $this->assertEquals(2, count($db['stages'])); |
||
| 48 | |||
| 49 | // Stage 1 |
||
| 50 | $this->assertEquals([ |
||
| 51 | 'x_pos' => 225, |
||
| 52 | 'y_pos' => 315, |
||
| 53 | 'color' => '#d30000', |
||
| 54 | ], $db['stages'][0]); |
||
| 55 | |||
| 56 | // Stage 2 |
||
| 57 | $this->assertEquals([ |
||
| 58 | 'x_pos' => 280, |
||
| 59 | 'y_pos' => 360, |
||
| 60 | 'color' => '#d30000', |
||
| 61 | ], $db['stages'][1]); |
||
| 62 | |||
| 63 | // Number of players |
||
| 64 | $this->assertEquals(4, count($db['players'])); |
||
| 65 | |||
| 66 | // Player 1 |
||
| 67 | $this->assertEquals([ |
||
| 68 | 'nick' => 'Orange', |
||
| 69 | 'x_pos' => 195, |
||
| 70 | 'y_pos' => 315, |
||
| 71 | 'color' => '#0080e1', |
||
| 72 | ], $db['players'][0]); |
||
| 73 | |||
| 74 | // Player 2 |
||
| 75 | $this->assertEquals([ |
||
| 76 | 'nick' => 'pi', |
||
| 77 | 'x_pos' => 225, |
||
| 78 | 'y_pos' => 270, |
||
| 79 | 'color' => '#0080e1', |
||
| 80 | ], $db['players'][1]); |
||
| 81 | |||
| 82 | // Player 3 |
||
| 83 | $this->assertEquals([ |
||
| 84 | 'nick' => 'BernardoRafael', |
||
| 85 | 'x_pos' => 225, |
||
| 86 | 'y_pos' => 315, |
||
| 87 | 'color' => '#0080e1', |
||
| 88 | ], $db['players'][2]); |
||
| 89 | |||
| 90 | // Player 4 |
||
| 91 | $this->assertEquals([ |
||
| 92 | 'nick' => 'pirilampo', |
||
| 93 | 'x_pos' => 225, |
||
| 94 | 'y_pos' => 315, |
||
| 95 | 'color' => '#0080e1', |
||
| 96 | ], $db['players'][3]); |
||
| 97 | } |
||
| 167 |