Completed
Push — configchanges ( 5a22dd...6fed49 )
by
unknown
02:59
created

BugherdHeroToolTest::testModusTestNoMember()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 20
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 20
loc 20
rs 9.4285
cc 1
eloc 15
nc 1
nop 0
1
<?php
2
class BugherdHeroToolTest extends FunctionalTest
3
{
4
    protected static $fixture_file = 'SiteTreeTest.yml';
5
    public static $use_draft_site = true;
6
    private $bugherd_string = 'sidebarv2.js?apikey=';
7
    /**
8
     * Test checks if an bugherd key was entered
9
     */
10
    public function testProjectKey()
11
    {
12
        Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx');
13
        $project_key = Config::inst()->get('BugherdHeroTool', 'project_key');
14
        $this->assertTrue(is_string($project_key), "Can't find your Bugherd project_key, please insert the key into your _config.yml");
15
    }
16
17
18
19
    public function testMemberStatus()
20
    {
21
        Config::inst()->update('BugherdHeroTool', 'member_status', true);
22
        Config::inst()->update('Director', 'environment_type', 'dev');
23
        Config::inst()->update('BugherdHeroTool', 'environment_type', 'dev');
24
        Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx');
25
26
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
27
        $body = strpos($response->getBody(), $this->bugherd_string);
28
        $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedModeMember'), array('loggedOut')));
29
30
        $cmseditor = $this->objFromFixture('Member', 'cmseditor');
31
        $cmseditor->logIn();
32
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
33
        $body = strpos($response->getBody(), $this->bugherd_string);
34
        $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedModeMember'), array('loggedIn')));
35
    }
36
37
    /**
38
     * Test checks if the bugherd template can be found in the template implementation
39
     */
40
    public function testModusDevNoMember()
41
    {
42
        Config::inst()->update('BugherdHeroTool', 'environment_type', 'dev');
43
        Config::inst()->update('Director', 'environment_type', 'dev');
44
        Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx');
45
46
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
47
        $body = strpos($response->getBody(), $this->bugherd_string);
48
        $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('dev', 'dev')));
49
50
        Config::inst()->update('Director', 'environment_type', 'test');
51
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
52
        $body = strpos($response->getBody(), $this->bugherd_string);
53
        $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('dev', 'test')));
54
55
        Config::inst()->update('Director', 'environment_type', 'live');
56
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
57
        $body = strpos($response->getBody(), $this->bugherd_string);
58
        $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('dev', 'live')));
59
    }
60
61
    public function testModusTestNoMember()
62
    {
63
        Config::inst()->update('BugherdHeroTool', 'environment_type', 'test');
64
        Config::inst()->update('Director', 'environment_type', 'test');
65
        Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx');
66
67
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
68
        $body = strpos($response->getBody(), $this->bugherd_string);
69
        $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('test', 'test')));
70
71
        Config::inst()->update('Director', 'environment_type', 'dev');
72
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
73
        $body = strpos($response->getBody(), $this->bugherd_string);
74
        $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('test', 'dev')));
75
76
        Config::inst()->update('Director', 'environment_type', 'live');
77
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
78
        $body = strpos($response->getBody(), $this->bugherd_string);
79
        $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('test', 'live')));
80
    }
81
82
    public function testModusLiveNoMember()
83
    {
84
        Config::inst()->update('BugherdHeroTool', 'environment_type', 'live');
85
        Config::inst()->update('Director', 'environment_type', 'live');
86
        Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx');
87
88
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
89
        $body = strpos($response->getBody(), $this->bugherd_string);
90
        $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('live', 'live')));
91
92
        Config::inst()->update('Director', 'environment_type', 'dev');
93
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
94
        $body = strpos($response->getBody(), $this->bugherd_string);
95
        $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('live', 'dev')));
96
97
        Config::inst()->update('Director', 'environment_type', 'test');
98
        $response = $this->get($this->objFromFixture('Page', 'home')->Link());
99
        $body = strpos($response->getBody(), $this->bugherd_string);
100
        $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('live', 'test')));
101
    }
102
}
103