| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 30 |
| 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 |
||
| 54 | public function testExecutePaginated() |
||
| 55 | { |
||
| 56 | $task = $this->createTask('Test workload 1'); |
||
| 57 | |||
| 58 | /** @var TaskExecutionInterface[] $executions */ |
||
| 59 | $executions = [ |
||
| 60 | $this->createTaskExecution($task, new \DateTime('-1 hour')), |
||
| 61 | $this->createTaskExecution($task, new \DateTime('-2 hour')), |
||
| 62 | $this->createTaskExecution($task, new \DateTime('+1 hour')), |
||
| 63 | ]; |
||
| 64 | |||
| 65 | $this->taskExecutionRepository->flush(); |
||
| 66 | |||
| 67 | $this->commandTester->execute( |
||
| 68 | [ |
||
| 69 | 'command' => $this->command->getName(), |
||
| 70 | '--page-size' => 2, |
||
| 71 | ] |
||
| 72 | ); |
||
| 73 | |||
| 74 | $output = $this->commandTester->getDisplay(); |
||
| 75 | $this->assertContains($executions[0]->getUuid(), $output); |
||
| 76 | $this->assertContains($executions[1]->getUuid(), $output); |
||
| 77 | $this->assertNotContains($executions[2]->getUuid(), $output); |
||
| 78 | |||
| 79 | $this->commandTester->execute( |
||
| 80 | [ |
||
| 81 | 'command' => $this->command->getName(), |
||
| 82 | '--page' => 2, |
||
| 83 | '--page-size' => 2, |
||
| 84 | ] |
||
| 85 | ); |
||
| 86 | |||
| 87 | $output = $this->commandTester->getDisplay(); |
||
| 88 | $this->assertNotContains($executions[0]->getUuid(), $output); |
||
| 89 | $this->assertNotContains($executions[1]->getUuid(), $output); |
||
| 90 | $this->assertContains($executions[2]->getUuid(), $output); |
||
| 91 | |||
| 92 | $this->commandTester->execute( |
||
| 93 | [ |
||
| 94 | 'command' => $this->command->getName(), |
||
| 95 | '--page' => 3, |
||
| 96 | '--page-size' => 2, |
||
| 97 | ] |
||
| 98 | ); |
||
| 99 | |||
| 100 | $output = $this->commandTester->getDisplay(); |
||
| 101 | $this->assertNotContains($executions[0]->getUuid(), $output); |
||
| 102 | $this->assertNotContains($executions[1]->getUuid(), $output); |
||
| 103 | $this->assertNotContains($executions[2]->getUuid(), $output); |
||
| 104 | } |
||
| 105 | |||
| 114 |