Passed
Pull Request — master (#133)
by
unknown
02:21
created

QueuedJobsTestService::flushJobs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
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
    public function queueJob(QueuedJob $job, $startAfter = null, $userId = null, $queueName = null)
25
    {
26
        $this->jobs[] = $job;
27
28
        return 1;
29
    }
30
31
    public static function reset()
32
    {
33
        self::singleton()->flushJobs();
34
    }
35
36
    public function onShutdown()
37
    {
38
    }
39
}
40