Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 36 |
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 |
||
66 | public function testEditUserEmail() { |
||
67 | $_COOKIE['epuser_id'] = '1.5ce7f6e2d7de4db00c297e1da0d48ac'; |
||
68 | $u = new THEUSER(); |
||
69 | $u->loggedin = 1; |
||
70 | |||
71 | $this->assertEquals('[email protected]', $u->email()); |
||
72 | |||
73 | $d = $u->update_self([ |
||
74 | 'firstname' => 'Experiment', |
||
75 | 'lastname' => 'User', |
||
76 | 'email' => '[email protected]', |
||
77 | 'postcode' => 'EH1 99SP', |
||
78 | 'password' => '', |
||
79 | 'url' => '', |
||
80 | 'optin' => 0, |
||
81 | 'user_id' => 1, |
||
82 | ], false); |
||
83 | |||
84 | // email should not change as user needs to confirm |
||
85 | $this->assertEquals('[email protected]', $u->email()); |
||
86 | |||
87 | $tokenCount = $this->getRowCount('tokens', 'data = "1::[email protected]"'); |
||
88 | $this->assertEquals(1, $tokenCount, 'correct number of email confirm tokens'); |
||
89 | |||
90 | // token is based on the time so we can't test for it |
||
91 | $queryTable = self::$db->query( |
||
92 | 'SELECT type, data FROM tokens WHERE data = "1::[email protected]"' |
||
93 | )->fetch(); |
||
94 | |||
95 | $this->assertEquals('E', $queryTable['type']); |
||
96 | $this->assertEquals('1::[email protected]', $queryTable['data']); |
||
97 | |||
98 | $alertCount = $this->getRowCount('alerts', 'email = "[email protected]"'); |
||
99 | $this->assertEquals(1, $alertCount, 'correct number of alerts'); |
||
100 | |||
101 | $tokenRow = self::$db->query( |
||
102 | 'SELECT token, type, data FROM tokens WHERE data = "1::[email protected]"' |
||
103 | )->fetch(); |
||
104 | |||
105 | $token = '2-' . $tokenRow['token']; |
||
106 | |||
107 | $u->confirm_email($token, false); |
||
108 | |||
109 | $this->assertEquals('[email protected]', $u->email(), 'confirming with token updates email address'); |
||
110 | $tokenCount = $this->getRowCount('tokens', 'data = "1::[email protected]"'); |
||
111 | $this->assertEquals(0, $tokenCount, 'token deleted once email confirmed'); |
||
112 | |||
113 | $alertCount = $this->getRowCount('alerts', 'email = "[email protected]"'); |
||
114 | $this->assertEquals(1, $alertCount, 'one alert for new email address'); |
||
115 | |||
116 | $alertCount = $this->getRowCount('alerts', 'email = "[email protected]"'); |
||
117 | $this->assertEquals(0, $alertCount, 'no alerts for old email address'); |
||
118 | } |
||
140 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.