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

CronJobTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAll() 0 16 1
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