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

SiteTreePublishingEngineTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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