Issues (27)

tests/php/QueuedJobsTestService.php (3 issues)

1
<?php
2
3
namespace SilverStripe\StaticPublishQueue\Test;
4
5
use SilverStripe\Core\Resettable;
6
use SilverStripe\Dev\TestOnly;
7
use Symbiote\QueuedJobs\Services\QueuedJob;
8
use Symbiote\QueuedJobs\Services\QueuedJobService;
9
10
class QueuedJobsTestService extends QueuedJobService implements Resettable, TestOnly
11
{
12
    private $jobs = [];
13
14
    public function flushJobs(): void
15
    {
16
        $this->jobs = [];
17
    }
18
19
    public function getJobs(): array
20
    {
21
        return $this->jobs;
22
    }
23
24
    /**
25
     * Keep the jobs in-memory for unit test purposes (avoid writes and related actions)
26
     *
27
     * @param QueuedJob $job
28
     * @param null $startAfter
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $startAfter is correct as it would always require null to be passed?
Loading history...
29
     * @param null $userId
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $userId is correct as it would always require null to be passed?
Loading history...
30
     * @param null $queueName
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $queueName is correct as it would always require null to be passed?
Loading history...
31
     * @return int
32
     */
33
    public function queueJob(QueuedJob $job, $startAfter = null, $userId = null, $queueName = null)
34
    {
35
        $this->jobs[] = $job;
36
37
        return 1;
38
    }
39
40
    public static function reset()
41
    {
42
        self::singleton()->flushJobs();
43
    }
44
45
    /**
46
     * Skip shutdown function actions
47
     */
48
    public function onShutdown()
49
    {
50
    }
51
}
52