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

CronTest::testSimpleCronJobRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 20
rs 9.6
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 Cron\Lib\Cron;
16
use Saito\Test\SaitoTestCase;
17
18
class CronTest extends SaitoTestCase
19
{
20
    public function testSimpleCronJobRun()
21
    {
22
        $cron = new Cron();
23
        $mock = $this->getMockBuilder('stdClass')
24
            ->setMethods(['callback'])
25
            ->getMock();
26
        $mock->expects($this->exactly(2))->method('callback');
27
        $cron->addCronJob('foo', '+1 day', [$mock, 'callback']);
28
29
        $mock = $this->getMockBuilder('stdClass')
30
            ->setMethods(['callback'])
31
            ->getMock();
32
        $mock->expects($this->exactly(3))->method('callback');
33
        $cron->addCronJob('bar', '-1 day', [$mock, 'callback']);
34
35
        $cron->execute();
36
        $cron->execute();
37
        $cron->clearHistory();
38
        $cron->execute();
39
    }
40
}
41