Code Duplication    Length = 21-21 lines in 4 locations

Tests/Model/WorkerTest.php 4 locations

@@ 21-41 (lines=21) @@
18
        $this->worker->setJobManager($this->jobManager);
19
    }
20
21
    public function testAt()
22
    {
23
        $time = time() + 2600;
24
        $job = $this->worker->at($time)->fibonacci(20);
25
        self::assertJob($job, $time, 'fibonacci');
26
27
        // Test at with priority
28
        $priority = 1024;
29
        $job = $this->worker->at($time, false, $priority)->fibonacci(20);
30
        self::assertJob($job, $time, 'fibonacci', $priority);
31
        self::assertFalse($job->getBatch(), 'Should not be batching');
32
33
        // Test job with object
34
        try {
35
            $object = new \stdClass();
36
            $this->worker->at($time)->fibonacci($object);
37
            self::fail('Exception should be thrown.');
38
        } catch (\Exception $e) {
39
            self::assertTrue(true);
40
        }
41
    }
42
43
    public function testLater()
44
    {
@@ 43-63 (lines=21) @@
40
        }
41
    }
42
43
    public function testLater()
44
    {
45
        $time = null;
46
        $job = $this->worker->later()->fibonacci(20);
47
        self::assertJob($job, $time, 'fibonacci');
48
        self::assertFalse($job->getBatch(), 'Should not be batching');
49
50
        // Test later with priority
51
        $priority = 1024;
52
        $job = $this->worker->later(0, $priority)->fibonacci(20);
53
        self::assertJob($job, $time, 'fibonacci', $priority);
54
55
        // Test job with object
56
        try {
57
            $object = new \stdClass();
58
            $this->worker->later($time)->fibonacci($object);
59
            self::fail('Exception should be thrown.');
60
        } catch (\Exception $e) {
61
            self::assertTrue(true);
62
        }
63
    }
64
65
    public function testBatchLater()
66
    {
@@ 65-85 (lines=21) @@
62
        }
63
    }
64
65
    public function testBatchLater()
66
    {
67
        $time = null;
68
        $job = $this->worker->batchLater()->fibonacci(20);
69
        self::assertJob($job, $time, 'fibonacci');
70
        self::assertTrue($job->getBatch(), 'Should be batching');
71
72
        // Test batchLater with priority
73
        $priority = 1024;
74
        $job = $this->worker->batchLater(0, $priority)->fibonacci(20);
75
        self::assertJob($job, $time, 'fibonacci', $priority);
76
77
        // Test job with object
78
        try {
79
            $object = new \stdClass();
80
            $this->worker->batchLater($time)->fibonacci($object);
81
            self::fail('Exception should be thrown.');
82
        } catch (\Exception $e) {
83
            self::assertTrue(true);
84
        }
85
    }
86
87
    public function testBatchAt()
88
    {
@@ 87-107 (lines=21) @@
84
        }
85
    }
86
87
    public function testBatchAt()
88
    {
89
        $time = time() + 3600;
90
        $job = $this->worker->batchAt($time)->fibonacci(20);
91
        self::assertJob($job, $time, 'fibonacci');
92
        self::assertTrue($job->getBatch(), 'Should be batching');
93
94
        // Test priority
95
        $priority = 1024;
96
        $job = $this->worker->batchAt($time, $priority)->fibonacci(20);
97
        self::assertJob($job, $time, 'fibonacci', $priority);
98
99
        // Test job with object
100
        try {
101
            $object = new \stdClass();
102
            $this->worker->batchAt($time)->fibonacci($object);
103
            self::fail('Exception should be thrown.');
104
        } catch (\Exception $e) {
105
            self::assertTrue(true);
106
        }
107
    }
108
109
    /**
110
     * @param int|null $time