Passed
Push — master ( 25ca2a...86c16b )
by Robbie
02:46
created

CWPSiteConfigExtensionTest::setUp()   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
class CWPSiteConfigExtensionTest extends SapphireTest
4
{
5
    protected $usesDatabase = true;
6
7
    /**
8
     * Nest the configuration for these tests
9
     *
10
     * {@inheritDoc}
11
     */
12
    public function setUp()
13
    {
14
        parent::setUp();
15
        Config::nest();
16
        Config::inst()->update('SSViewer', 'theme', CWP_THEME_NAME);
0 ignored issues
show
Bug introduced by
The constant CWP_THEME_NAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
17
    }
18
19
    /**
20
     * Ensure that other fields that are removed are only removed when the CWP theme is enabled
21
     */
22
    public function testFieldsAreRemovedWhenUsingCwpTheme()
23
    {
24
        $fields = SiteConfig::create()->getCMSFields();
25
        $this->assertNull($fields->fieldByName('Root.LogosIcons.LogoRetina'));
26
    }
27
28
    /**
29
     * Test that the existing fields are not removed when not using the CWP theme
30
     */
31
    public function testFieldsAreNotRemovedWhenNotUsingCwpTheme()
32
    {
33
        Config::inst()->update('SSViewer', 'theme', 'simple');
34
        $fields = SiteConfig::create()->getCMSFields();
35
        $this->assertInstanceOf(SelectUploadField::class, $fields->fieldByName('Root.LogosIcons.LogoRetina'));
0 ignored issues
show
Bug introduced by
The type SelectUploadField was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
36
    }
37
38
    /**
39
     * Ensure that the two "search caption" fields exist and are in the right tab
40
     */
41
    public function testConfigurableSearchLabelsExistAndAreInCorrectTab()
42
    {
43
        $fields = SiteConfig::create()->getCMSFields();
44
        $this->assertInstanceOf(TextField::class, $fields->fieldByName('Root.SearchOptions.EmptySearch'));
45
        $this->assertInstanceOf(TextField::class, $fields->fieldByName('Root.SearchOptions.NoSearchResults'));
46
    }
47
48
    /**
49
     * Unnest the configuration after these tests
50
     *
51
     * {@inheritDoc}
52
     */
53
    public function tearDown()
54
    {
55
        Config::unnest();
56
        parent::tearDown();
57
    }
58
}
59