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

SiteTreePublishingEngineTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 19
c 3
b 0
f 0
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCollectChangesForUnpublishing() 0 12 1
A testCollectChangesForPublishing() 0 12 1
A setUp() 0 5 1
1
<?php
2
3
namespace SilverStripe\StaticPublishQueue\Test;
4
5
use Psr\Log\LoggerInterface;
6
use SilverStripe\Core\Injector\Injector;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\StaticPublishQueue\Test\SiteTreePublishingEngineTest\Model\StaticPublishingTriggerPage;
9
10
class SiteTreePublishingEngineTest extends SapphireTest
11
{
12
    protected function setUp()
13
    {
14
        parent::setUp();
15
16
        Injector::inst()->registerService(@$this->createMock(LoggerInterface::class), LoggerInterface::class);
17
    }
18
19
    public function testCollectChangesForPublishing()
20
    {
21
        $obj = StaticPublishingTriggerPage::create();
22
        $obj->collectChanges(['action' => 'publish']);
23
24
        $this->assertSame(
25
            '/updateOnPublish',
26
            $obj->getToUpdate()->first()->url
27
        );
28
        $this->assertSame(
29
            '/deleteOnPublish',
30
            $obj->getToDelete()->first()->url
31
        );
32
    }
33
34
    public function testCollectChangesForUnpublishing()
35
    {
36
        $obj = StaticPublishingTriggerPage::create();
37
        $obj->collectChanges(['action' => 'unpublish']);
38
39
        $this->assertSame(
40
            '/updateOnUnpublish',
41
            $obj->getToUpdate()->first()->url
42
        );
43
        $this->assertSame(
44
            '/deleteOnUnpublish',
45
            $obj->getToDelete()->first()->url
46
        );
47
    }
48
}
49