1 | <?php |
||||||
2 | |||||||
3 | namespace TractorCow\Fluent\Tests\Extension; |
||||||
4 | |||||||
5 | use Page; |
||||||
0 ignored issues
–
show
|
|||||||
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 | } |
||||||
33 | |||||||
34 | public function testAugmentSQLFrontend() |
||||||
35 | { |
||||||
36 | FluentState::singleton()->withState(function (FluentState $newState) { |
||||||
37 | $newState |
||||||
38 | ->setLocale('en_NZ') |
||||||
39 | ->setIsFrontend(true) |
||||||
40 | ->setIsDomainMode(false); |
||||||
41 | |||||||
42 | $this->assertEquals(1, SiteTree::get()->count()); |
||||||
43 | }); |
||||||
44 | } |
||||||
45 | |||||||
46 | public function testAugmentSQLCMS() |
||||||
47 | { |
||||||
48 | FluentState::singleton()->withState(function (FluentState $newState) { |
||||||
49 | $newState |
||||||
50 | ->setLocale('en_NZ') |
||||||
51 | ->setIsFrontend(false) |
||||||
52 | ->setIsDomainMode(false); |
||||||
53 | |||||||
54 | $this->assertEquals(2, SiteTree::get()->count()); |
||||||
55 | }); |
||||||
56 | } |
||||||
57 | |||||||
58 | public function testUpdateCMSFields() |
||||||
59 | { |
||||||
60 | FluentState::singleton()->withState(function (FluentState $newState) { |
||||||
61 | $newState |
||||||
62 | ->setLocale('en_NZ') |
||||||
63 | ->setIsDomainMode(false); |
||||||
64 | |||||||
65 | /** @var Page|FluentSiteTreeExtension $page */ |
||||||
66 | $page = SiteTree::get()->filter('URLSegment', 'home')->first(); |
||||||
67 | $fields = $page->getCMSFields(); |
||||||
0 ignored issues
–
show
The method
getCMSFields() does not exist on TractorCow\Fluent\Extens...FluentSiteTreeExtension .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
68 | |||||||
69 | $this->assertNotNull($fields->dataFieldByName('FilteredLocales')); |
||||||
70 | }); |
||||||
71 | } |
||||||
72 | |||||||
73 | public function testUpdateStatusFlags() |
||||||
74 | { |
||||||
75 | FluentState::singleton()->withState(function (FluentState $newState) { |
||||||
76 | $newState |
||||||
77 | ->setLocale('en_US') |
||||||
78 | ->setIsFrontend(false) |
||||||
79 | ->setIsDomainMode(false); |
||||||
80 | |||||||
81 | /** @var Page|FluentSiteTreeExtension $page */ |
||||||
82 | $page = $this->objFromFixture('Page', 'about'); |
||||||
83 | $flags = $page->getStatusFlags(); |
||||||
0 ignored issues
–
show
The method
getStatusFlags() does not exist on TractorCow\Fluent\Extens...FluentSiteTreeExtension .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||||
84 | |||||||
85 | $this->assertTrue(array_key_exists('fluentfiltered', $flags)); |
||||||
86 | |||||||
87 | if (!array_key_exists('fluentfiltered', $flags)) { |
||||||
88 | return; |
||||||
89 | } |
||||||
90 | |||||||
91 | $this->assertEquals('Filtered', $flags['fluentfiltered']['text']); |
||||||
92 | }); |
||||||
93 | } |
||||||
94 | } |
||||||
95 |
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