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

DefaultThemeExtensionTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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