Completed
Push — master ( 381a7e...8ac8f4 )
by Marcus
9s
created

CleanupJobTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * @author Andrew Aitken-Fincham <[email protected]>
5
 */
6
class CleanupJobTest extends SapphireTest {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
8
    protected static $fixture_file = 'CleanupJobFixture.yml';
9
10
    public function setUp() {
11
        parent::setUp();
12
        // Have to set a fake time here to work with 
13
        // the LastEdited dates in the fixture
14
        SS_Datetime::set_mock_now("02-02-03 02:02:02");
15
    }
16
17
    public function tearDown() {
18
        parent::tearDown();
19
        SS_Datetime::clear_mock_now();
20
    }
21
22 View Code Duplication
    public function testByDays() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
        $job = new CleanupJob();
24
        Config::inst()->update('CleanupJob', 'cleanup_method', 'age');
25
        Config::inst()->update('CleanupJob', 'cleanup_value', 30);
26
        Config::inst()->remove('CleanupJob', 'cleanup_statuses');
27
        Config::inst()->update('CleanupJob', 'cleanup_statuses',
28
            array('Broken', 'Complete'));
29
        $job->process();
30
        $data = $job->getJobData();
31
        $this->assertContains("2 jobs cleaned up.", $data->messages[0]);
32
    }
33
34 View Code Duplication
    public function testByNumber() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
        $job = new CleanupJob();
36
        Config::inst()->update('CleanupJob', 'cleanup_method', 'number');
37
        Config::inst()->update('CleanupJob', 'cleanup_value', 3);
38
        Config::inst()->remove('CleanupJob', 'cleanup_statuses');
39
        Config::inst()->update('CleanupJob', 'cleanup_statuses',
40
            array('Broken', 'Complete'));
41
        $job->process();
42
        $data = $job->getJobData();
43
        $this->assertContains("2 jobs cleaned up.", $data->messages[0]);
44
    }
45
46 View Code Duplication
    public function testByStatus() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
47
        $job = new CleanupJob();
48
        Config::inst()->update('CleanupJob', 'cleanup_method', 'number');
49
        Config::inst()->update('CleanupJob', 'cleanup_value', 3);
50
        Config::inst()->remove('CleanupJob', 'cleanup_statuses');
51
        Config::inst()->update('CleanupJob', 'cleanup_statuses',
52
            array('Broken', 'Complete', 'New'));
53
        $job->process();
54
        $data = $job->getJobData();
55
        $this->assertContains("3 jobs cleaned up.", $data->messages[0]);
56
    }
57
58 View Code Duplication
    public function testNoCleanup() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
        $job = new CleanupJob();
60
        Config::inst()->update('CleanupJob', 'cleanup_method', 'number');
61
        Config::inst()->update('CleanupJob', 'cleanup_value', 6);
62
        Config::inst()->remove('CleanupJob', 'cleanup_statuses');
63
        Config::inst()->update('CleanupJob', 'cleanup_statuses',
64
            array('Broken', 'Complete', 'New'));
65
        $job->process();
66
        $data = $job->getJobData();
67
        $this->assertContains("No jobs to clean up.", $data->messages[0]);
68
    }
69
70
}
71