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\FluentFilteredExtension; |
9
|
|
|
use TractorCow\Fluent\Extension\FluentSiteTreeExtension; |
10
|
|
|
use TractorCow\Fluent\Model\Domain; |
11
|
|
|
use TractorCow\Fluent\Model\Locale; |
12
|
|
|
use TractorCow\Fluent\State\FluentState; |
13
|
|
|
|
14
|
|
|
class FluentFilteredExtensionTest extends SapphireTest |
15
|
|
|
{ |
16
|
|
|
protected static $fixture_file = 'FluentFilteredExtensionTest.yml'; |
17
|
|
|
|
18
|
|
|
protected static $required_extensions = [ |
19
|
|
|
SiteTree::class => [ |
20
|
|
|
FluentSiteTreeExtension::class, |
21
|
|
|
FluentFilteredExtension::class, |
22
|
|
|
], |
23
|
|
|
]; |
24
|
|
|
|
25
|
|
|
protected function setUp() |
26
|
|
|
{ |
27
|
|
|
parent::setUp(); |
28
|
|
|
|
29
|
|
|
// Clear cache |
30
|
|
|
Locale::clearCached(); |
31
|
|
|
Domain::clearCached(); |
32
|
|
|
FluentState::singleton() |
33
|
|
|
->setLocale('en_NZ') |
34
|
|
|
->setIsDomainMode(false); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testAugmentSQLFrontend() |
38
|
|
|
{ |
39
|
|
|
FluentState::singleton() |
40
|
|
|
->setLocale('en_NZ') |
41
|
|
|
->setIsFrontend(true); |
42
|
|
|
|
43
|
|
|
$this->assertEquals(1, SiteTree::get()->count()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testAugmentSQLCMS() |
47
|
|
|
{ |
48
|
|
|
FluentState::singleton() |
49
|
|
|
->setLocale('en_NZ') |
50
|
|
|
->setIsFrontend(false); |
51
|
|
|
|
52
|
|
|
$this->assertEquals(2, SiteTree::get()->count()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testUpdateCMSFields() |
56
|
|
|
{ |
57
|
|
|
/** @var Page|FluentSiteTreeExtension $page */ |
58
|
|
|
$page = SiteTree::get()->filter('URLSegment', 'home')->first(); |
59
|
|
|
$fields = $page->getCMSFields(); |
|
|
|
|
60
|
|
|
|
61
|
|
|
$this->assertNotNull($fields->dataFieldByName('FilteredLocales')); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testUpdateStatusFlags() |
65
|
|
|
{ |
66
|
|
|
FluentState::singleton() |
67
|
|
|
->setLocale('en_US') |
68
|
|
|
->setIsFrontend(false); |
69
|
|
|
|
70
|
|
|
/** @var Page|FluentSiteTreeExtension $page */ |
71
|
|
|
$page = $this->objFromFixture('Page', 'about'); |
72
|
|
|
$flags = $page->getStatusFlags(); |
|
|
|
|
73
|
|
|
|
74
|
|
|
$this->assertTrue(array_key_exists('fluentfiltered', $flags)); |
75
|
|
|
|
76
|
|
|
if (!array_key_exists('fluentfiltered', $flags)) { |
77
|
|
|
return; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$this->assertEquals('Filtered', $flags['fluentfiltered']['text']); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
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