Completed
Branch hotfix/5.4.1 (9732a4)
by Schlaefer
02:32
created

CronJobTest::testAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Saito - The Threaded Web Forum
7
 *
8
 * @copyright Copyright (c) the Saito Project Developers
9
 * @link https://github.com/Schlaefer/Saito
10
 * @license http://opensource.org/licenses/MIT
11
 */
12
13
namespace Cron\Test;
14
15
use Cake\TestSuite\TestCase;
16
use Cron\Lib\CronJob;
17
18
class CronJobTest extends TestCase
19
{
20
    public function testAll()
21
    {
22
        $mock = $this->getMockBuilder('stdClass')
23
            ->setMethods(['callback'])
24
            ->getMock();
25
        $mock->expects($this->once())->method('callback');
26
27
        $due = '+1 day';
28
        $job = new CronJob('foo', $due, [$mock, 'callback']);
29
30
        $this->assertEquals('foo', $job->getUid());
31
        $due = new \DateTimeImmutable($due);
32
        $this->assertWithinRange($due->getTimestamp(), $job->getDue(), 2);
33
34
        $job->execute();
35
    }
36
}
37