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

testRenamedDefaultThemeCanBeDetected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 7
loc 7
rs 9.4285
1
<?php
2
3
class CwpThemeHelperTest extends SapphireTest
4
{
5
    protected $usesDatabase = true;
6
7
    /**
8
     * Ensure that the "default" theme can be detected correctly via configuration settings
9
     */
10 View Code Duplication
    public function testDetectDefaultThemeViaConfig()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
    {
12
        Config::inst()->update('SSViewer', 'theme_enabled', true);
13
        Config::inst()->update('SSViewer', 'theme', 'default');
14
        $this->assertTrue(CwpThemeHelper::singleton()->getIsDefaultTheme());
15
16
        Config::inst()->update('SSViewer', 'theme', 'starter');
17
        $this->assertFalse(CwpThemeHelper::singleton()->getIsDefaultTheme());
18
    }
19
20
    /**
21
     * Ensure that the "default" theme can be detected correctly via SiteConfig
22
     */
23
    public function testDetectDefaultThemeViaSiteConfig()
24
    {
25
        $siteConfig = SiteConfig::current_site_config();
26
        $siteConfig->Theme = 'default';
27
        $siteConfig->write();
28
        $siteConfig->flushCache();
29
30
        $this->assertTrue(CwpThemeHelper::singleton()->getIsDefaultTheme());
31
32
        $siteConfig->Theme = 'starter';
33
        $siteConfig->write();
34
        $siteConfig->flushCache();
35
36
        $this->assertFalse(CwpThemeHelper::singleton()->getIsDefaultTheme());
37
    }
38
39
    /**
40
     * Ensure that a customised default theme name can be detected
41
     */
42 View Code Duplication
    public function testRenamedDefaultThemeCanBeDetected()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        Config::inst()->update('SSViewer', 'theme_enabled', true);
45
        Config::inst()->update('SSViewer', 'theme', 'default-but-updated');
46
        Config::inst()->update('CwpThemeHelper', 'default_themes', array('default-but-updated'));
47
48
        $this->assertTrue(CwpThemeHelper::singleton()->getIsDefaultTheme());
49
    }
50
}
51