Source of file GoogleAnalyticsTemplateGlobalProviderTest.php
Size: 1,445 Bytes - Last Modified: 2021-12-23T10:38:23+00:00
/var/www/docs.ssmods.com/process/src/tests/TemplateGlobalProviders/GoogleAnalyticsTemplateGlobalProviderTest.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | <?php namespace StudioBonito\SilverStripe\GoogleAnalytics\Tests\TemplateGlobalProviders; use Injector; use Mockery as m; use StudioBonito\SilverStripe\GoogleAnalytics\TemplateGlobalProviders\GoogleAnalyticsTemplateGlobalProvider; /** * GoogleAnalyticsTemplateGlobalProviderTest. * * @author Tom Densham <tom.densham@studiobonito.co.uk> * @copyright Studio Bonito Ltd. */ class GoogleAnalyticsTemplateGlobalProviderTest extends \PHPUnit_Framework_TestCase { public function tearDown() { m::close(); } public function testGetTemplateGlobalVariables() { $templateProvider = new GoogleAnalyticsTemplateGlobalProvider(); $variables = $templateProvider->get_template_global_variables(); $this->assertArrayHasKey('GoogleAnalytics', $variables); } public function testGetGoogleAnalyticsScript() { $mockConfig = m::mock('StdClass'); $mockConfig->GoogleAnalyticsTrackingID = 'UA-12345678-1'; $mockSiteConfig = m::mock('SiteConfig') ->shouldReceive('current_site_config') ->once() ->andReturn($mockConfig) ->getMock(); Injector::inst()->registerService($mockSiteConfig, 'SiteConfig'); $templateProvider = new GoogleAnalyticsTemplateGlobalProvider(); $script = $templateProvider->getGoogleAnalyticsScript(); $this->assertRegExp('/UA-12345678-1/', $script); } } |