Completed
Push — master ( 5203af...6fbdfb )
by Robbie
01:54
created

ChecExtensionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetChecJs() 0 5 1
A testGetChecJsIgnoresIfFalsy() 0 5 1
A setUp() 0 4 1
1
<?php
2
3
namespace Robbie\SilverstripeChec\Tests;
4
5
use Robbie\SilverstripeChec\ChecExtension;
6
use Robbie\SilverstripeChec\ChecShortcode;
7
use SilverStripe\CMS\Model\SiteTree;
8
use SilverStripe\Dev\SapphireTest;
9
10
class ChecExtensionTest extends SapphireTest
11
{
12
    protected static $fixture_file = 'ChecIOShortcodeTest.yml';
13
14
    /**
15
     * @var SiteTree&ChecExtension
16
     */
17
    private $page;
18
19
    protected function setUp()
20
    {
21
        parent::setUp();
22
        $this->page = $this->objFromFixture(SiteTree::class, 'test');
23
    }
24
25
    /**
26
     * Tests that a non-empty result is returned.
27
     */
28
    public function testGetChecJs()
29
    {
30
        $result = $this->page->getChecJavaScript();
31
        $this->assertNotNull($result);
32
        $this->assertContains('<script type="text/javascript', $result);
33
    }
34
35
    /**
36
     * Allow the JS to be disabled if desired
37
     */
38
    public function testGetChecJsIgnoresIfFalsy()
39
    {
40
        ChecShortcode::config()->set('third-party-js', '');
41
        $result = $this->page->getChecJavaScript();
42
        $this->assertNotContains('<script type="text/javascript', $result);
43
    }
44
}
45