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

testAddCustomStylesAndScripts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 14
loc 14
rs 9.4285
1
<?php
2
3
class DefaultThemeExtensionTest extends SapphireTest
4
{
5
    protected $requiredExtensions = array(
6
        'BasePage_Controller' => array('DefaultThemeExtension', 'DefaultThemeExtensionStub')
7
    );
8
9
    /**
10
     * @var BasePage_Controller
11
     */
12
    protected $controller;
13
14
    public function setUp()
15
    {
16
        parent::setUp();
17
18
        if (!is_dir(BASE_PATH . '/themes/default')) {
19
            $this->markTestSkipped('These tests require the default theme to be installed');
20
        }
21
22
        $this->controller = BasePage_Controller::create();
23
        $this->controller->init();
24
    }
25
26 View Code Duplication
    public function testAddCustomStylesAndScripts()
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...
27
    {
28
        Config::inst()->update('DefaultThemeExtension', 'disable_default_styles', false);
29
        Config::inst()->update('DefaultThemeExtension', 'disable_default_scripts', false);
30
31
        $this->controller->extend('onAfterInit');
32
33
        $javascript = Requirements::backend()->get_javascript();
34
        $this->assertContains('agency-extensions/tests/Extensions/Stub/agencytest.js', $javascript);
35
        $this->assertContains('themes/default/js/general.js', $javascript);
36
37
        $css = Requirements::backend()->get_css();
38
        $this->assertArrayHasKey('agency-extensions/tests/Extensions/Stub/agencytest.css', $css);
39
        $this->assertArrayHasKey('themes/default/css/layout.css', $css);
40
    }
41
42 View Code Duplication
    public function testDefaultAssetsAreNotAddedWhenDisabledWithConfig()
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('DefaultThemeExtension', 'disable_default_scripts', true);
45
        $this->controller->extend('onAfterInit');
46
        $javascript = Requirements::backend()->get_javascript();
47
        $this->assertContains('agency-extensions/tests/Extensions/Stub/agencytest.js', $javascript);
48
        $this->assertNotContains('themes/default/js/general.js', $javascript);
49
50
        Config::inst()->update('DefaultThemeExtension', 'disable_default_styles', true);
51
        $this->controller->extend('onAfterInit');
52
        $css = Requirements::backend()->get_css();
53
        $this->assertArrayHasKey('agency-extensions/tests/Extensions/Stub/agencytest.css', $css);
54
        $this->assertArrayNotHasKey('themes/default/css/layout.css', $css);
55
    }
56
}
57