Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 31 |
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 |
||
26 | public function testGetServerCharset(): void |
||
27 | { |
||
28 | $this->dummyDbi->addResult( |
||
29 | 'SHOW SESSION VARIABLES LIKE \'character_set_server\';', |
||
30 | [ |
||
31 | [ |
||
32 | 'character_set_server', |
||
33 | 'utf8mb3', |
||
34 | ], |
||
35 | ], |
||
36 | [ |
||
37 | 'Variable_name', |
||
38 | 'Value', |
||
39 | ] |
||
40 | ); |
||
41 | $this->dummyDbi->addResult( |
||
42 | 'SHOW SESSION VARIABLES LIKE \'character_set_server\';', |
||
43 | false |
||
44 | ); |
||
45 | $this->dummyDbi->addResult( |
||
46 | 'SELECT @@character_set_server;', |
||
47 | false |
||
48 | ); |
||
49 | $this->dummyDbi->addResult( |
||
50 | 'SHOW SESSION VARIABLES LIKE \'character_set_server\';', |
||
51 | false |
||
52 | ); |
||
53 | $this->dummyDbi->addResult( |
||
54 | 'SELECT @@character_set_server;', |
||
55 | [ |
||
56 | ['utf8mb3'], |
||
57 | ] |
||
58 | ); |
||
59 | |||
60 | $charset = Charsets::getServerCharset( |
||
61 | $GLOBALS['dbi'], |
||
62 | $GLOBALS['cfg']['Server']['DisableIS'] |
||
63 | ); |
||
64 | $this->assertSame('utf8', $charset->getName()); |
||
65 | |||
66 | $charset = Charsets::getServerCharset( |
||
67 | $GLOBALS['dbi'], |
||
68 | $GLOBALS['cfg']['Server']['DisableIS'] |
||
69 | ); |
||
70 | $this->assertSame('Unknown', $charset->getName()); |
||
71 | |||
72 | $charset = Charsets::getServerCharset( |
||
73 | $GLOBALS['dbi'], |
||
74 | $GLOBALS['cfg']['Server']['DisableIS'] |
||
75 | ); |
||
76 | $this->assertSame('utf8', $charset->getName()); |
||
77 | |||
78 | $this->assertAllQueriesConsumed(); |
||
79 | } |
||
112 |