Completed
Push — master ( 86c16b...d765f6 )
by Robbie
7s
created

testConfigurableSearchLabelsExistAndAreInCorrectTab()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
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