Completed
Push — master ( 0820f1...730af2 )
by Daniel
21s queued 10s
created

QueuedJobsTestService::onShutdown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
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