| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 126 | public function testEventStatusActionStatus() |
||
| 127 | { |
||
| 128 | // Create a action and translation |
||
| 129 | $action = new \stdClass(); |
||
| 130 | $action->id = 'new-worker-action-id'; |
||
| 131 | $action->description = new \stdClass(); |
||
| 132 | $action->description->en = "Some translated action"; |
||
| 133 | |||
| 134 | $client = static::createRestClient(); |
||
| 135 | $client->put('/event/action/'.$action->id, $action); |
||
| 136 | |||
| 137 | // Check result |
||
| 138 | $this->assertEquals(204, $client->getResponse()->getStatusCode()); |
||
| 139 | |||
| 140 | // get our object again |
||
| 141 | $client = static::createRestClient(); |
||
| 142 | $client->request('GET', '/event/action/'.$action->id); |
||
| 143 | $results = $client->getResults(); |
||
| 144 | $this->assertEquals($action->description->en, $results->description->en); |
||
| 145 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
||
| 146 | |||
| 147 | // Creating the event |
||
| 148 | $eventStatus = new \stdClass(); |
||
| 149 | $eventStatus->id = 'mynewstatus2'; |
||
| 150 | $eventStatus->createDate = '2015-09-24T07:21:24+0000'; |
||
| 151 | $eventStatus->eventName = 'document.test.app.create'; |
||
| 152 | |||
| 153 | $status = new \stdClass(); |
||
| 154 | $status->workerId = 'testworker'; |
||
| 155 | $status->status = 'opened'; |
||
| 156 | $status->action = new \stdClass(); |
||
| 157 | $status->action->{'$ref'} = 'http://localhost/event/action/'.$action->id; |
||
| 158 | $eventStatus->status = [$status]; |
||
| 159 | |||
| 160 | // Save the status |
||
| 161 | $client = static::createRestClient(); |
||
| 162 | $client->put('/event/status/mynewstatus2', $eventStatus); |
||
| 163 | |||
| 164 | $this->assertNull($client->getResults()); |
||
| 165 | $this->assertNull($client->getResponse()->headers->get('Location')); |
||
| 166 | $this->assertEquals(204, $client->getResponse()->getStatusCode()); |
||
| 167 | |||
| 168 | // get our object again, checking |
||
| 169 | $client = static::createRestClient(); |
||
| 170 | $client->request('GET', '/event/status/mynewstatus2'); |
||
| 171 | $results = $client->getResults(); |
||
| 172 | |||
| 173 | $this->assertEquals('opened', $results->status[0]->status); |
||
| 174 | $this->assertEquals('http://localhost/event/action/'.$action->id, $results->status[0]->action->{'$ref'}); |
||
| 175 | |||
| 176 | } |
||
| 177 | } |
||
| 178 |