Passed
Pull Request — master (#362)
by Robbie
02:11
created

testSourceLocaleIsCurrentWhenPageExistsInIt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace TractorCow\Fluent\Tests\Extension;
4
5
use Page;
0 ignored issues
show
Bug introduced by
The type Page 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...
6
use SilverStripe\CMS\Model\SiteTree;
7
use SilverStripe\Dev\SapphireTest;
8
use TractorCow\Fluent\Extension\FluentSiteTreeExtension;
9
use TractorCow\Fluent\Model\Domain;
10
use TractorCow\Fluent\Model\Locale;
11
use TractorCow\Fluent\State\FluentState;
12
13
class FluentVersionedExtensionTest extends SapphireTest
14
{
15
    protected static $fixture_file = 'FluentVersionedExtensionTest.yml';
16
17
    protected static $required_extensions = [
18
        SiteTree::class => [
19
            FluentSiteTreeExtension::class,
20
        ],
21
    ];
22
23
    protected function setUp()
24
    {
25
        parent::setUp();
26
27
        // Clear cache
28
        Locale::clearCached();
29
        Domain::clearCached();
30
        FluentState::singleton()
31
            ->setLocale('en_NZ')
32
            ->setIsDomainMode(false);
33
    }
34
35
    public function testIsDraftedInLocale()
36
    {
37
        /** @var Page $page */
38
        $page = $this->objFromFixture(Page::class, 'home');
39
40
        $this->assertTrue($page->isDraftedInLocale());
41
    }
42
43
    public function testIsPublishedInLocale()
44
    {
45
        /** @var Page $page */
46
        $page = $this->objFromFixture(Page::class, 'home');
47
48
        $this->assertTrue($page->isPublishedInLocale());
49
    }
50
51
    public function testExistsInLocale()
52
    {
53
        /** @var Page $page */
54
        $page = $this->objFromFixture(Page::class, 'home');
55
56
        $this->assertTrue($page->existsInLocale());
57
    }
58
59
    /** @group wip */
60
    public function testSourceLocaleIsCurrentWhenPageExistsInIt()
61
    {
62
        // Read from the locale that the page exists in already
63
        /** @var Page $page */
64
        $page = $this->objFromFixture(Page::class, 'home');
65
66
        $this->assertEquals('en_NZ', $page->getSourceLocale()->Locale);
67
    }
68
}
69