Conditions | 1 |
Paths | 1 |
Total Lines | 84 |
Code Lines | 59 |
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 |
||
27 | public function testHttpMethodOverrides() |
||
28 | { |
||
29 | $request = new HTTPRequest( |
||
30 | 'GET', |
||
31 | 'admin/crm' |
||
32 | ); |
||
33 | $this->assertTrue( |
||
34 | $request->isGET(), |
||
35 | 'GET with no method override' |
||
36 | ); |
||
37 | |||
38 | $request = new HTTPRequest( |
||
39 | 'POST', |
||
40 | 'admin/crm' |
||
41 | ); |
||
42 | $this->assertTrue( |
||
43 | $request->isPOST(), |
||
44 | 'POST with no method override' |
||
45 | ); |
||
46 | |||
47 | $request = new HTTPRequest( |
||
48 | 'GET', |
||
49 | 'admin/crm', |
||
50 | array('_method' => 'DELETE') |
||
51 | ); |
||
52 | $this->assertTrue( |
||
53 | $request->isGET(), |
||
54 | 'GET with invalid POST method override' |
||
55 | ); |
||
56 | |||
57 | $request = new HTTPRequest( |
||
58 | 'POST', |
||
59 | 'admin/crm', |
||
60 | array(), |
||
61 | array('_method' => 'DELETE') |
||
62 | ); |
||
63 | $this->assertTrue( |
||
64 | $request->isDELETE(), |
||
65 | 'POST with valid method override to DELETE' |
||
66 | ); |
||
67 | |||
68 | $request = new HTTPRequest( |
||
69 | 'POST', |
||
70 | 'admin/crm', |
||
71 | array(), |
||
72 | array('_method' => 'put') |
||
73 | ); |
||
74 | $this->assertTrue( |
||
75 | $request->isPUT(), |
||
76 | 'POST with valid method override to PUT' |
||
77 | ); |
||
78 | |||
79 | $request = new HTTPRequest( |
||
80 | 'POST', |
||
81 | 'admin/crm', |
||
82 | array(), |
||
83 | array('_method' => 'head') |
||
84 | ); |
||
85 | $this->assertTrue( |
||
86 | $request->isHEAD(), |
||
87 | 'POST with valid method override to HEAD ' |
||
88 | ); |
||
89 | |||
90 | $request = new HTTPRequest( |
||
91 | 'POST', |
||
92 | 'admin/crm', |
||
93 | array(), |
||
94 | array('_method' => 'head') |
||
95 | ); |
||
96 | $this->assertTrue( |
||
97 | $request->isHEAD(), |
||
98 | 'POST with valid method override to HEAD' |
||
99 | ); |
||
100 | |||
101 | $request = new HTTPRequest( |
||
102 | 'POST', |
||
103 | 'admin/crm', |
||
104 | array('_method' => 'head') |
||
105 | ); |
||
106 | $this->assertTrue( |
||
107 | $request->isPOST(), |
||
108 | 'POST with invalid method override by GET parameters to HEAD' |
||
109 | ); |
||
110 | } |
||
111 | |||
290 |