1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TractorCow\Fluent\Tests\Extension; |
4
|
|
|
|
5
|
|
|
use Page; |
|
|
|
|
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
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testIsDraftedInLocale() |
33
|
|
|
{ |
34
|
|
|
FluentState::singleton()->withState(function (FluentState $newState) { |
35
|
|
|
$newState |
36
|
|
|
->setLocale('en_NZ') |
37
|
|
|
->setIsDomainMode(false); |
38
|
|
|
|
39
|
|
|
/** @var Page $page */ |
40
|
|
|
$page = $this->objFromFixture(Page::class, 'home'); |
41
|
|
|
|
42
|
|
|
$this->assertTrue($page->isDraftedInLocale()); |
43
|
|
|
}); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testIsPublishedInLocale() |
47
|
|
|
{ |
48
|
|
|
FluentState::singleton()->withState(function (FluentState $newState) { |
49
|
|
|
$newState |
50
|
|
|
->setLocale('en_NZ') |
51
|
|
|
->setIsDomainMode(false); |
52
|
|
|
|
53
|
|
|
/** @var Page $page */ |
54
|
|
|
$page = $this->objFromFixture(Page::class, 'home'); |
55
|
|
|
|
56
|
|
|
$this->assertTrue($page->isPublishedInLocale()); |
57
|
|
|
}); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testExistsInLocale() |
61
|
|
|
{ |
62
|
|
|
FluentState::singleton()->withState(function (FluentState $newState) { |
63
|
|
|
$newState |
64
|
|
|
->setLocale('en_NZ') |
65
|
|
|
->setIsDomainMode(false); |
66
|
|
|
|
67
|
|
|
/** @var Page $page */ |
68
|
|
|
$page = $this->objFromFixture(Page::class, 'home'); |
69
|
|
|
|
70
|
|
|
$this->assertTrue($page->existsInLocale()); |
71
|
|
|
}); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** @group wip */ |
75
|
|
|
public function testSourceLocaleIsCurrentWhenPageExistsInIt() |
76
|
|
|
{ |
77
|
|
|
FluentState::singleton()->withState(function (FluentState $newState) { |
78
|
|
|
$newState |
79
|
|
|
->setLocale('en_NZ') |
80
|
|
|
->setIsDomainMode(false); |
81
|
|
|
|
82
|
|
|
// Read from the locale that the page exists in already |
83
|
|
|
/** @var Page $page */ |
84
|
|
|
$page = $this->objFromFixture(Page::class, 'home'); |
85
|
|
|
|
86
|
|
|
$this->assertEquals('en_NZ', $page->getSourceLocale()->Locale); |
87
|
|
|
}); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths