Rewrite mocks to nicer variants
[MAILPOET-2539]
This commit is contained in:
committed by
Jack Kitterhing
parent
04f266518b
commit
a5ec593568
@@ -71,17 +71,15 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
|||||||
'token' => 123,
|
'token' => 123,
|
||||||
];
|
];
|
||||||
|
|
||||||
$run = 0;
|
$cron_worker_runner_mock = $this->createMock(CronWorkerRunner::class);
|
||||||
$cron_worker_runner_mock = $this->make(CronWorkerRunner::class, [
|
$cron_worker_runner_mock
|
||||||
'run' => function () use (&$run) {
|
->expects($this->at(0))
|
||||||
$run++;
|
->method('run')
|
||||||
if ($run === 1) {
|
->willThrowException(new \Exception('Message'));
|
||||||
throw new \Exception('Message');
|
$cron_worker_runner_mock
|
||||||
} elseif ($run === 2) {
|
->expects($this->at(1))
|
||||||
throw new \Exception();
|
->method('run')
|
||||||
}
|
->willThrowException(new \Exception());
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
$daemon = new Daemon($this->cron_helper, $cron_worker_runner_mock, $this->createWorkersFactoryMock());
|
$daemon = new Daemon($this->cron_helper, $cron_worker_runner_mock, $this->createWorkersFactoryMock());
|
||||||
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
||||||
@@ -218,17 +216,17 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testItUpdatesTimestampsDuringExecution() {
|
function testItUpdatesTimestampsDuringExecution() {
|
||||||
$run = 0;
|
$cron_worker_runner_mock = $this->createMock(CronWorkerRunner::class);
|
||||||
$cron_worker_runner_mock = $this->make(CronWorkerRunner::class, [
|
$cron_worker_runner_mock
|
||||||
'run' => function () use (&$run) {
|
->expects($this->at(0))
|
||||||
$run++;
|
->method('run')
|
||||||
if ($run === 1) {
|
->willReturnCallback(function () {
|
||||||
sleep(2);
|
sleep(2);
|
||||||
} elseif ($run === 2) {
|
});
|
||||||
throw new \Exception();
|
$cron_worker_runner_mock
|
||||||
}
|
->expects($this->at(1))
|
||||||
},
|
->method('run')
|
||||||
]);
|
->willThrowException(new \Exception());
|
||||||
|
|
||||||
$daemon = new Daemon($this->cron_helper, $cron_worker_runner_mock, $this->createWorkersFactoryMock());
|
$daemon = new Daemon($this->cron_helper, $cron_worker_runner_mock, $this->createWorkersFactoryMock());
|
||||||
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
$daemon_http_runner = $this->make(DaemonHttpRunner::class, [
|
||||||
|
Reference in New Issue
Block a user