10 use Symfony\Component\Console\Tester\CommandTester;
17 private $deploymentConfig;
27 private $commandTester;
37 private $readinessCheck;
46 $this->deploymentConfig = $this->createMock(\
Magento\Framework\
App\DeploymentConfig::class);
47 $this->queue = $this->createMock(\
Magento\Setup\Model\Cron\Queue::class);
48 $this->readinessCheck = $this->createMock(\
Magento\Setup\Model\Cron\ReadinessCheck::class);
49 $this->status = $this->createMock(\
Magento\Setup\Model\Cron\Status::class);
51 $this->deploymentConfig,
53 $this->readinessCheck,
56 $this->commandTester =
new CommandTester($this->command);
61 $this->deploymentConfig->expects($this->once())->method(
'isAvailable')->willReturn(
false);
62 $this->status->expects($this->once())->method($this->anything());
63 $this->queue->expects($this->never())->method($this->anything());
64 $this->readinessCheck->expects($this->never())->method($this->anything());
65 $this->commandTester->execute([]);
70 $this->deploymentConfig->expects($this->once())->method(
'isAvailable')->willReturn(
true);
71 $this->status->expects($this->never())->method($this->anything());
72 $this->queue->expects($this->never())->method($this->anything());
73 $this->readinessCheck->expects($this->once())->method(
'runReadinessCheck')->willReturn(
false);
74 $this->commandTester->execute([]);
79 $this->deploymentConfig->expects($this->once())->method(
'isAvailable')->willReturn(
true);
80 $this->queue->expects($this->never())->method($this->anything());
81 $this->readinessCheck->expects($this->once())->method(
'runReadinessCheck')->willReturn(
true);
82 $this->status->expects($this->once())->method(
'isUpdateInProgress')->willReturn(
true);
83 $this->status->expects($this->never())->method(
'add');
84 $this->status->expects($this->never())->method(
'isUpdateError');
85 $this->commandTester->execute([]);
90 $this->deploymentConfig->expects($this->once())->method(
'isAvailable')->willReturn(
true);
91 $this->queue->expects($this->never())->method($this->anything());
92 $this->readinessCheck->expects($this->once())->method(
'runReadinessCheck')->willReturn(
true);
93 $this->status->expects($this->once())->method(
'isUpdateInProgress')->willReturn(
false);
94 $this->status->expects($this->never())->method(
'add');
95 $this->status->expects($this->once())->method(
'isUpdateError')->willReturn(
true);
96 $this->commandTester->execute([]);
101 $this->deploymentConfig->expects($this->once())->method(
'isAvailable')->willReturn(
true);
102 $this->queue->expects($this->never())->method($this->anything());
103 $this->readinessCheck->expects($this->once())->method(
'runReadinessCheck')->willReturn(
true);
104 $this->status->expects($this->once())->method(
'isUpdateInProgress')->willReturn(
false);
105 $this->status->expects($this->once())->method(
'add')->with(
'runtime exception');
106 $this->status->expects($this->once())->method(
'isUpdateError')->willReturn(
false);
107 $this->status->expects($this->once())
108 ->method(
'toggleUpdateInProgress')
110 $this->commandTester->execute([]);
115 $this->deploymentConfig->expects($this->once())->method(
'isAvailable')->willReturn(
true);
116 $this->readinessCheck->expects($this->once())->method(
'runReadinessCheck')->willReturn(
true);
117 $this->status->expects($this->once())->method(
'isUpdateInProgress')->willReturn(
false);
118 $this->status->expects($this->once())->method(
'isUpdateError')->willReturn(
false);
119 $this->status->expects($this->exactly(2))->method(
'toggleUpdateInProgress');
125 $this->queue->expects($this->once())->method(
'peek')->willReturn([]);
126 $this->queue->expects($this->never())->method(
'popQueuedJob');
127 $this->commandTester->execute([]);
133 $this->queue->expects($this->exactly(2))->method(
'peek')->willReturn([
'name' =>
'update']);
134 $this->queue->expects($this->never())->method(
'popQueuedJob');
135 $this->commandTester->execute([]);
141 $this->queue->expects($this->exactly(2))->method(
'peek')->willReturn([
'name' =>
'setup:']);
142 $this->queue->expects($this->once())->method(
'popQueuedJob')->willThrowException(
new \
Exception(
'pop failed'));
143 $this->status->expects($this->once())->method(
'add')->with(
'pop failed');
144 $this->status->expects($this->once())->method(
'toggleUpdateError')->with(
true);
145 $this->commandTester->execute([]);
151 $this->queue->expects($this->at(0))->method(
'peek')->willReturn([
'name' =>
'setup:']);
152 $this->queue->expects($this->at(1))->method(
'peek')->willReturn([
'name' =>
'setup:']);
153 $job = $this->getMockForAbstractClass(\
Magento\Setup\Model\Cron\AbstractJob::class, [],
'',
false);
154 $job->expects($this->once())->method(
'execute')->willThrowException(
new \
Exception(
'job failed'));
155 $this->queue->expects($this->at(2))->method(
'popQueuedJob')->willReturn($job);
156 $this->status->expects($this->atLeastOnce())->method(
'toggleUpdateError')->with(
true);
157 $this->commandTester->execute([]);
163 $this->queue->expects($this->at(0))->method(
'peek')->willReturn([
'name' =>
'setup:']);
164 $this->queue->expects($this->at(1))->method(
'peek')->willReturn([
'name' =>
'setup:']);
165 $job = $this->getMockForAbstractClass(\
Magento\Setup\Model\Cron\AbstractJob::class, [],
'',
false);
166 $job->expects($this->once())->method(
'execute');
167 $this->queue->expects($this->at(2))->method(
'popQueuedJob')->willReturn($job);
168 $this->status->expects($this->never())->method(
'toggleUpdateError')->with(
true);
169 $this->commandTester->execute([]);
testExecuteNotInstalled()
testExecutePopQueueFails()
testExecuteErrorOnToggleInProgress()
testExecuteNoJobInQueue()
testExecuteFirstJobNotSupported()
setUpPreliminarySuccess()
testExecuteFailedReadinessCheck()
testExecuteUpdateInProgress()