Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 34 |
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 |
||
19 | public function testRequestResetting() |
||
20 | { |
||
21 | $client = static::createClient(); |
||
22 | $client->enableProfiler(); |
||
23 | $client->request('POST', '/resetting/request', ['username' => 'iqhjioqiosois']); |
||
24 | |||
25 | // On vérifie que l'email a été envoyé |
||
26 | $mailCollector = $client->getProfile()->getCollector('swiftmailer'); |
||
27 | $this->assertEquals(0, $mailCollector->getMessageCount()); |
||
|
|||
28 | $this->assertJsonResponse($client->getResponse(), 404); |
||
29 | |||
30 | $client = static::createClient(); |
||
31 | $client->enableProfiler(); |
||
32 | $client->request('POST', '/resetting/request', ['username' => 'trancara']); |
||
33 | |||
34 | // On vérifie que l'email a été envoyé |
||
35 | $mailCollector = $client->getProfile()->getCollector('swiftmailer'); |
||
36 | $this->assertEquals(1, $mailCollector->getMessageCount()); |
||
37 | $this->assertJsonResponse($client->getResponse(), 204); |
||
38 | |||
39 | $collectedMessages = $mailCollector->getMessages(); |
||
40 | $message = $collectedMessages[0]; |
||
41 | |||
42 | // On vérifie le message |
||
43 | $this->assertInstanceOf('Swift_Message', $message); |
||
44 | $this->assertEquals('Réinitialisation du mot de passe', $message->getSubject()); |
||
45 | $this->assertEquals('[email protected]', key($message->getFrom())); |
||
46 | $this->assertEquals('[email protected]', key($message->getTo())); |
||
47 | |||
48 | // On récupère le token |
||
49 | $this->assertTrue(preg_match('#/reset/(.*)\n\n.*Si#is', $message->getBody(), $token) == 1); |
||
50 | $token = $token[1]; |
||
51 | $this->assertTrue(!empty($token)); |
||
52 | |||
53 | // On teste le reset en lui même |
||
54 | $this->client->request('POST', '/resetting/token/dfdsdsfdsfsfds', ['password' => '1234', 'check' => '1234']); |
||
55 | $this->assertJsonResponse($this->client->getResponse(), 404); |
||
56 | |||
57 | $this->client->request('POST', '/resetting/token/'.$token, ['password' => 'password', 'check' => '12sdqsdsqdqds34']); |
||
58 | $this->assertJsonResponse($this->client->getResponse(), 400); |
||
59 | |||
60 | $this->client->request('POST', '/resetting/token/'.$token, ['password' => 'azerty', 'check' => 'azerty']); |
||
61 | $this->assertJsonResponse($this->client->getResponse(), 204); |
||
62 | |||
63 | // On vérifie que le mot de passe a bien été changé |
||
64 | $client = static::createClient(); |
||
65 | $client->request('POST', '/login', ['username' => 'trancara', 'password' => 'azerty']); |
||
66 | $this->assertJsonResponse($client->getResponse(), 200, true); |
||
67 | |||
68 | // On remet l'ancien mot de passe |
||
69 | $client = static::createClient(); |
||
70 | $client->request('POST', '/resetting/token/'.$token, ['password' => 'password', 'check' => 'password']); |
||
71 | $this->assertJsonResponse($this->client->getResponse(), 204); |
||
72 | } |
||
73 | } |
||
74 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.