1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TractorCow\Fluent\Tests\Extension; |
4
|
|
|
|
5
|
|
|
use Page; |
|
|
|
|
6
|
|
|
use SilverStripe\CMS\Model\SiteTree; |
7
|
|
|
use SilverStripe\Control\Director; |
8
|
|
|
use SilverStripe\Core\Config\Config; |
9
|
|
|
use SilverStripe\Dev\SapphireTest; |
10
|
|
|
use SilverStripe\ORM\ArrayList; |
11
|
|
|
use SilverStripe\View\ArrayData; |
12
|
|
|
use TractorCow\Fluent\Extension\FluentSiteTreeExtension; |
13
|
|
|
use TractorCow\Fluent\Model\Locale; |
14
|
|
|
use TractorCow\Fluent\State\FluentState; |
15
|
|
|
use TractorCow\Fluent\Tests\Extension\Stub\FluentStubObject; |
16
|
|
|
|
17
|
|
|
class FluentSiteTreeExtensionTest extends SapphireTest |
18
|
|
|
{ |
19
|
|
|
protected static $fixture_file = 'FluentSiteTreeExtensionTest.yml'; |
20
|
|
|
|
21
|
|
|
protected static $required_extensions = [ |
22
|
|
|
SiteTree::class => [FluentSiteTreeExtension::class], |
23
|
|
|
FluentStubObject::class => [FluentSiteTreeExtension::class], |
24
|
|
|
]; |
25
|
|
|
|
26
|
|
|
protected function setUp() |
27
|
|
|
{ |
28
|
|
|
parent::setUp(); |
29
|
|
|
|
30
|
|
|
Config::inst()->update(Director::class, 'alternate_base_url', 'http://mocked'); |
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testGetLocaleInformation() |
34
|
|
|
{ |
35
|
|
|
$result = $this->objFromFixture(Page::class, 'nz-page')->LocaleInformation('en_NZ'); |
36
|
|
|
|
37
|
|
|
$this->assertInstanceOf(ArrayData::class, $result); |
38
|
|
|
$this->assertEquals([ |
39
|
|
|
'Locale' => 'en_NZ', |
40
|
|
|
'LocaleRFC1766' => 'en-NZ', |
41
|
|
|
'Title' => 'English (New Zealand)', |
42
|
|
|
'LanguageNative' => 'English', |
43
|
|
|
'Language' => 'en', |
44
|
|
|
'Link' => '/newzealand/a-page/', |
45
|
|
|
'AbsoluteLink' => 'http://mocked/newzealand/a-page/', |
46
|
|
|
'LinkingMode' => 'link', |
47
|
|
|
'URLSegment' => 'newzealand' |
48
|
|
|
], $result->toMap()); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testGetLocales() |
52
|
|
|
{ |
53
|
|
|
$result = $this->objFromFixture(Page::class, 'nz-page')->Locales(); |
54
|
|
|
|
55
|
|
|
$this->assertInstanceOf(ArrayList::class, $result); |
56
|
|
|
$this->assertCount(2, $result); |
57
|
|
|
$this->assertDOSEquals([ |
|
|
|
|
58
|
|
|
['Locale' => 'en_NZ'], |
59
|
|
|
['Locale' => 'de_DE'], |
60
|
|
|
], $result); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testGetLinkingMode() |
64
|
|
|
{ |
65
|
|
|
// Does not have a canViewInLocale method, locale is not current |
66
|
|
|
$this->assertSame('link', (new FluentStubObject)->getLinkingMode('foo')); |
|
|
|
|
67
|
|
|
|
68
|
|
|
// Does not have a canViewInLocale method, locale is current |
69
|
|
|
FluentState::singleton()->setLocale('foo'); |
70
|
|
|
$this->assertSame('current', (new FluentStubObject)->getLinkingMode('foo')); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
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