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