Conditions | 1 |
Paths | 1 |
Total Lines | 63 |
Code Lines | 46 |
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 |
||
7 | public function testAutocomplete() |
||
8 | { |
||
9 | $this->client->request('GET', '/admin/media/autocomplete'); |
||
10 | |||
11 | $response = $this->getLastResponse(); |
||
12 | $this->assertEquals('KO', $response['status']); |
||
13 | $this->assertEquals('Search string too short', $response['message']); |
||
14 | |||
15 | $this->client->request('GET', '/admin/media/autocomplete', [ |
||
16 | 'q' => 'media' |
||
17 | ]); |
||
18 | |||
19 | $response = $this->getLastResponse(); |
||
20 | $this->assertEquals('OK', $response['status']); |
||
21 | $this->assertEmpty($response['more']); |
||
22 | $this->assertEmpty($response['items']); |
||
23 | |||
24 | $this->uploadImage(); |
||
25 | |||
26 | $this->client->request('GET', '/admin/media/autocomplete', [ |
||
27 | 'q' => 'monk' |
||
28 | ]); |
||
29 | $response = $this->getLastResponse(); |
||
30 | $this->assertEquals('OK', $response['status']); |
||
31 | $this->assertEmpty($response['more']); |
||
32 | $this->assertCount(1, $response['items']); |
||
33 | |||
34 | $this->client->request('GET', '/admin/media/autocomplete', [ |
||
35 | 'q' => 'monk', |
||
36 | 'type' => 'image' |
||
37 | ]); |
||
38 | $response = $this->getLastResponse(); |
||
39 | $this->assertEquals('OK', $response['status']); |
||
40 | $this->assertEmpty($response['more']); |
||
41 | $this->assertCount(1, $response['items']); |
||
42 | |||
43 | $this->client->request('GET', '/admin/media/autocomplete', [ |
||
44 | 'q' => 'monk', |
||
45 | 'type' => 'audio' |
||
46 | ]); |
||
47 | $response = $this->getLastResponse(); |
||
48 | $this->assertEquals('OK', $response['status']); |
||
49 | $this->assertEmpty($response['more']); |
||
50 | $this->assertCount(0, $response['items']); |
||
51 | |||
52 | $this->client->request('GET', '/admin/media/autocomplete', [ |
||
53 | 'q' => 'monk', |
||
54 | 'provider' => 'image' |
||
55 | ]); |
||
56 | $response = $this->getLastResponse(); |
||
57 | $this->assertEquals('OK', $response['status']); |
||
58 | $this->assertEmpty($response['more']); |
||
59 | $this->assertCount(1, $response['items']); |
||
60 | |||
61 | $this->client->request('GET', '/admin/media/autocomplete', [ |
||
62 | 'q' => 'monk', |
||
63 | 'provider' => 'soundcloud' |
||
64 | ]); |
||
65 | $response = $this->getLastResponse(); |
||
66 | $this->assertEquals('OK', $response['status']); |
||
67 | $this->assertEmpty($response['more']); |
||
68 | $this->assertCount(0, $response['items']); |
||
69 | } |
||
70 | |||
79 |