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