Conditions | 1 |
Paths | 1 |
Total Lines | 69 |
Code Lines | 48 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 testIndex(): void |
||
27 | { |
||
28 | global $dbi, $db, $server, $cfg, $PMA_PHP_SELF, $is_grantuser, $is_createuser; |
||
29 | |||
30 | $db = 'db'; |
||
31 | $server = 0; |
||
32 | $cfg['Server']['DisableIS'] = false; |
||
33 | $PMA_PHP_SELF = 'index.php'; |
||
34 | $is_grantuser = true; |
||
35 | $is_createuser = true; |
||
36 | |||
37 | $privileges = []; |
||
38 | |||
39 | $serverPrivileges = $this->createMock(Privileges::class); |
||
40 | $serverPrivileges->method('getAllPrivileges') |
||
41 | ->willReturn($privileges); |
||
42 | |||
43 | $controller = new PrivilegesController( |
||
44 | Response::getInstance(), |
||
45 | $dbi, |
||
46 | new Template(), |
||
47 | $db, |
||
48 | $serverPrivileges |
||
49 | ); |
||
50 | $actual = $controller->index(['checkprivsdb' => $db]); |
||
51 | |||
52 | $this->assertStringContainsString( |
||
53 | Url::getCommon(['db' => $db], ''), |
||
54 | $actual |
||
55 | ); |
||
56 | |||
57 | $this->assertStringContainsString( |
||
58 | $db, |
||
59 | $actual |
||
60 | ); |
||
61 | |||
62 | $this->assertStringContainsString( |
||
63 | __('User'), |
||
64 | $actual |
||
65 | ); |
||
66 | $this->assertStringContainsString( |
||
67 | __('Host'), |
||
68 | $actual |
||
69 | ); |
||
70 | $this->assertStringContainsString( |
||
71 | __('Type'), |
||
72 | $actual |
||
73 | ); |
||
74 | $this->assertStringContainsString( |
||
75 | __('Privileges'), |
||
76 | $actual |
||
77 | ); |
||
78 | $this->assertStringContainsString( |
||
79 | __('Grant'), |
||
80 | $actual |
||
81 | ); |
||
82 | $this->assertStringContainsString( |
||
83 | __('Action'), |
||
84 | $actual |
||
85 | ); |
||
86 | |||
87 | //_pgettext('Create new user', 'New') |
||
88 | $this->assertStringContainsString( |
||
89 | _pgettext('Create new user', 'New'), |
||
90 | $actual |
||
91 | ); |
||
92 | $this->assertStringContainsString( |
||
93 | Url::getCommon(['checkprivsdb' => $db]), |
||
94 | $actual |
||
95 | ); |
||
98 |