|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CWP\AgencyExtensions\Tests\Extensions; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Forms\FileHandleField; |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
use SilverStripe\Core\Config\Config; |
|
10
|
|
|
use SilverStripe\Core\Environment; |
|
11
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
12
|
|
|
use SilverStripe\SiteConfig\SiteConfig; |
|
13
|
|
|
use SilverStripe\View\SSViewer; |
|
14
|
|
|
use SilverStripe\Forms\TextField; |
|
15
|
|
|
use CWP\AgencyExtensions\Extensions\CWPSiteConfigExtension; |
|
16
|
|
|
|
|
17
|
|
|
class CWPSiteConfigExtensionTest extends SapphireTest |
|
18
|
|
|
{ |
|
19
|
|
|
protected $usesDatabase = true; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Ensure that other fields that are removed are only removed when the CWP theme is enabled |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testRetinaFieldsAreRemovedByDefault() |
|
25
|
|
|
{ |
|
26
|
|
|
$fields = SiteConfig::create()->getCMSFields(); |
|
27
|
|
|
$this->assertNull($fields->fieldByName('Root.LogosIcons.LogoRetina')); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Test that the existing fields are not removed when not using the CWP theme |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testFieldsAreNotRemovedWhenConfiguredNotTo() |
|
34
|
|
|
{ |
|
35
|
|
|
Config::modify()->set(CWPSiteConfigExtension::class, 'hide_fields', null); |
|
36
|
|
|
$fields = SiteConfig::create()->getCMSFields(); |
|
37
|
|
|
$this->assertInstanceOf(FileHandleField::class, $fields->fieldByName('Root.LogosIcons.LogoRetina')); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Ensure that the two "search caption" fields exist and are in the right tab |
|
42
|
|
|
*/ |
|
43
|
|
|
public function testConfigurableSearchLabelsExistAndAreInCorrectTab() |
|
44
|
|
|
{ |
|
45
|
|
|
$fields = SiteConfig::create()->getCMSFields(); |
|
46
|
|
|
$this->assertInstanceOf(TextField::class, $fields->fieldByName('Root.SearchOptions.EmptySearch')); |
|
47
|
|
|
$this->assertInstanceOf(TextField::class, $fields->fieldByName('Root.SearchOptions.NoSearchResults')); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|