Source of file BugherdHeroToolTest.php
Size: 5,796 Bytes - Last Modified: 2021-12-23T10:06:40+00:00
/var/www/docs.ssmods.com/process/src/tests/BugherdHeroToolTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 | <?php class BugherdHeroToolTest extends FunctionalTest { protected static $fixture_file = 'SiteTreeTest.yml'; public static $use_draft_site = true; private $bugherd_string = 'sidebarv2.js?apikey='; /** * Test checks if an bugherd key was entered */ public function testProjectKey() { Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx'); $project_key = Config::inst()->get('BugherdHeroTool', 'project_key'); $this->assertTrue(is_string($project_key), "Can't find your Bugherd project_key, please insert the key into your _config.yml"); } public function testMemberStatus() { Config::inst()->update('BugherdHeroTool', 'member_status', true); Config::inst()->update('Director', 'environment_type', 'dev'); Config::inst()->update('BugherdHeroTool', 'environment_type', 'dev'); Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedModeMember'), array('loggedOut'))); $cmseditor = $this->objFromFixture('Member', 'cmseditor'); $cmseditor->logIn(); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedModeMember'), array('loggedIn'))); } /** * Test checks if the bugherd template can be found in the template implementation */ public function testModusDevNoMember() { Config::inst()->update('BugherdHeroTool', 'environment_type', 'dev'); Config::inst()->update('Director', 'environment_type', 'dev'); Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('dev', 'dev'))); Config::inst()->update('Director', 'environment_type', 'test'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('dev', 'test'))); Config::inst()->update('Director', 'environment_type', 'live'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('dev', 'live'))); } public function testModusTestNoMember() { Config::inst()->update('BugherdHeroTool', 'environment_type', 'test'); Config::inst()->update('Director', 'environment_type', 'test'); Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('test', 'test'))); Config::inst()->update('Director', 'environment_type', 'dev'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('test', 'dev'))); Config::inst()->update('Director', 'environment_type', 'live'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('test', 'live'))); } public function testModusLiveNoMember() { Config::inst()->update('BugherdHeroTool', 'environment_type', 'live'); Config::inst()->update('Director', 'environment_type', 'live'); Config::inst()->update('BugherdHeroTool', 'project_key', 'xxxx'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertTrue(is_numeric($body), _t('BugherdHeroToolTest.CantFindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('live', 'live'))); Config::inst()->update('Director', 'environment_type', 'dev'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('live', 'dev'))); Config::inst()->update('Director', 'environment_type', 'test'); $response = $this->get($this->objFromFixture('Page', 'home')->Link()); $body = strpos($response->getBody(), $this->bugherd_string); $this->assertFalse($body, _t('BugherdHeroToolTest.FindInTemplate').vsprintf(_t('BugherdHeroToolTest.ModeTestedMode'), array('live', 'test'))); } } |