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

SiteTreePublishingEngineTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 8
Bugs 0 Features 0
Metric Value
eloc 21
c 8
b 0
f 0
dl 0
loc 38
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCollectChangesForUnpublishing() 0 12 1
A testCollectChangesForPublishing() 0 12 1
A setUp() 0 7 1
1
<?php
2
3
namespace SilverStripe\StaticPublishQueue\Test;
4
5
use SilverStripe\Core\Config\Config;
6
use SilverStripe\Core\Injector\Injector;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\StaticPublishQueue\Test\SiteTreePublishingEngineTest\Model\StaticPublishingTriggerPage;
9
use Symbiote\QueuedJobs\Services\QueuedJobHandler;
10
use Symbiote\QueuedJobs\Services\QueuedJobService;
11
use Symbiote\QueuedJobs\Tests\QueuedJobsTest\QueuedJobsTest_Handler;
0 ignored issues
show
Bug introduced by
The type Symbiote\QueuedJobs\Test...\QueuedJobsTest_Handler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
class SiteTreePublishingEngineTest extends SapphireTest
14
{
15
    protected function setUp()
16
    {
17
        parent::setUp();
18
19
        Config::modify()->set(QueuedJobService::class, 'use_shutdown_function', false);
20
        Injector::inst()->registerService(new QueuedJobsTest_Handler(), QueuedJobHandler::class);
21
        Injector::inst()->registerService(new QueuedJobsTestService(), QueuedJobService::class);
22
    }
23
24
    public function testCollectChangesForPublishing()
25
    {
26
        $obj = StaticPublishingTriggerPage::create();
27
        $obj->collectChanges(['action' => 'publish']);
28
29
        $this->assertSame(
30
            '/updateOnPublish',
31
            $obj->getToUpdate()->first()->url
32
        );
33
        $this->assertSame(
34
            '/deleteOnPublish',
35
            $obj->getToDelete()->first()->url
36
        );
37
    }
38
39
    public function testCollectChangesForUnpublishing()
40
    {
41
        $obj = StaticPublishingTriggerPage::create();
42
        $obj->collectChanges(['action' => 'unpublish']);
43
44
        $this->assertSame(
45
            '/updateOnUnpublish',
46
            $obj->getToUpdate()->first()->url
47
        );
48
        $this->assertSame(
49
            '/deleteOnUnpublish',
50
            $obj->getToDelete()->first()->url
51
        );
52
    }
53
}
54