Conditions | 1 |
Paths | 1 |
Total Lines | 77 |
Code Lines | 58 |
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 |
||
45 | public function testIndexAction(): void |
||
46 | { |
||
47 | $charsets = [ |
||
48 | 'armscii8', |
||
49 | 'ascii', |
||
50 | 'big5', |
||
51 | 'binary', |
||
52 | ]; |
||
53 | $charsetsDescriptions = [ |
||
54 | 'armscii8' => 'PMA_armscii8_general_ci', |
||
55 | 'ascii' => 'PMA_ascii_general_ci', |
||
56 | 'big5' => 'PMA_big5_general_ci', |
||
57 | 'binary' => 'PMA_binary_general_ci', |
||
58 | ]; |
||
59 | $collations = [ |
||
60 | 'armscii8' => ['armscii8'], |
||
61 | 'ascii' => ['ascii'], |
||
62 | 'big5' => ['big5'], |
||
63 | 'binary' => ['binary'], |
||
64 | ]; |
||
65 | $defaultCollations = [ |
||
66 | 'armscii8' => 'armscii8', |
||
67 | 'ascii' => 'ascii', |
||
68 | 'big5' => 'big5', |
||
69 | 'binary' => 'binary', |
||
70 | ]; |
||
71 | |||
72 | $controller = new ServerCollationsController( |
||
73 | Response::getInstance(), |
||
74 | $GLOBALS['dbi'], |
||
75 | $charsets, |
||
76 | $charsetsDescriptions, |
||
77 | $collations, |
||
78 | $defaultCollations |
||
79 | ); |
||
80 | |||
81 | $actual = $controller->indexAction(); |
||
82 | |||
83 | $this->assertContains( |
||
84 | '<div id="div_mysql_charset_collations">', |
||
85 | $actual |
||
86 | ); |
||
87 | $this->assertContains( |
||
88 | __('Collation'), |
||
89 | $actual |
||
90 | ); |
||
91 | $this->assertContains( |
||
92 | __('Description'), |
||
93 | $actual |
||
94 | ); |
||
95 | $this->assertContains( |
||
96 | '<em>PMA_armscii8_general_ci</em>', |
||
97 | $actual |
||
98 | ); |
||
99 | $this->assertContains( |
||
100 | '<td>armscii8</td>', |
||
101 | $actual |
||
102 | ); |
||
103 | $this->assertContains( |
||
104 | '<td>' . Charsets::getCollationDescr('armscii8') . '</td>', |
||
|
|||
105 | $actual |
||
106 | ); |
||
107 | $this->assertContains( |
||
108 | '<em>PMA_ascii_general_ci</em>', |
||
109 | $actual |
||
110 | ); |
||
111 | $this->assertContains( |
||
112 | '<td>ascii</td>', |
||
113 | $actual |
||
114 | ); |
||
115 | $this->assertContains( |
||
116 | '<em>PMA_big5_general_ci</em>', |
||
117 | $actual |
||
118 | ); |
||
119 | $this->assertContains( |
||
120 | '<td>big5</td>', |
||
121 | $actual |
||
122 | ); |
||
125 |