Passed
Push — configchanges ( 8afa04...cd3932 )
by
unknown
02:43
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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");
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
    }
36
37
    /**
38
     * Test checks if the bugherd template can be found in the template implementation
39
     */
40 View Code Duplication
    public function testModusDevNoMember()
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...
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')));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
    }
60
61 View Code Duplication
    public function testModusTestNoMember()
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...
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')));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
80
    }
81
82 View Code Duplication
    public function testModusLiveNoMember()
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...
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')));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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')));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<BugherdHeroToolTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
101
    }
102
}
103