1 | <?php |
||
20 | class ScheduleTaskCommandTest extends BaseCommandTestCase |
||
21 | { |
||
22 | public function testExecute() |
||
23 | { |
||
24 | $this->commandTester->execute( |
||
25 | [ |
||
26 | 'command' => $this->command->getName(), |
||
27 | 'handlerClass' => TestHandler::class, |
||
28 | ] |
||
29 | ); |
||
30 | |||
31 | $tasks = $this->taskRepository->findAll(); |
||
32 | $this->assertCount(1, $tasks); |
||
33 | |||
34 | $this->assertEquals(TestHandler::class, $tasks[0]->getHandlerClass()); |
||
35 | |||
36 | $executions = $this->taskExecutionRepository->findAll(); |
||
37 | $this->assertCount(1, $executions); |
||
38 | |||
39 | $this->assertEquals(TestHandler::class, $executions[0]->getHandlerClass()); |
||
40 | } |
||
41 | |||
42 | public function testExecuteWithWorkload() |
||
58 | |||
59 | public function testExecuteWithWorkloadAndInterval() |
||
77 | |||
78 | public function testExecuteWithWorkloadAndIntervalAndEndDate() |
||
99 | |||
100 | public function testExecuteWithExecutionDate() |
||
101 | { |
||
102 | $date = new \DateTime('+1 day'); |
||
103 | $this->commandTester->execute( |
||
104 | [ |
||
105 | 'command' => $this->command->getName(), |
||
106 | 'handlerClass' => TestHandler::class, |
||
107 | 'workload' => 'Test workload 1', |
||
108 | '--execution-date' => '+1 day', |
||
109 | ] |
||
110 | ); |
||
111 | |||
112 | $tasks = $this->taskRepository->findAll(); |
||
113 | $this->assertCount(1, $tasks); |
||
114 | |||
115 | $this->assertEquals(TestHandler::class, $tasks[0]->getHandlerClass()); |
||
116 | $this->assertEquals($date, $tasks[0]->getFirstExecution()); |
||
117 | |||
118 | $executions = $this->taskExecutionRepository->findAll(); |
||
119 | $this->assertCount(1, $executions); |
||
120 | |||
121 | $this->assertEquals(TestHandler::class, $executions[0]->getHandlerClass()); |
||
122 | $this->assertEquals($date, $executions[0]->getScheduleTime()); |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | protected function getCommand() |
||
132 | } |
||
133 |