1 | <?php |
||
13 | class ClientIdProviderTest extends \PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | public function testGetClientId() |
||
16 | { |
||
17 | $provider = $this->getMockBuilder('Happyr\GoogleAnalyticsBundle\Service\ClientIdProvider') |
||
18 | ->setMethods(['getClientIdFormCookie']) |
||
19 | ->disableOriginalConstructor() |
||
20 | ->getMock(); |
||
21 | $provider->expects($this->once()) |
||
22 | ->method('getClientIdFormCookie') |
||
23 | ->willReturn(false); |
||
24 | |||
25 | $result = $provider->getClientId(); |
||
26 | |||
27 | $this->assertRegExp('|[0-9]{9}+|', $result, 'Not big and random enough'); |
||
28 | } |
||
29 | |||
30 | public function testExtractCookie() |
||
31 | { |
||
32 | $provider = new ProviderDummy(); |
||
33 | |||
34 | $this->assertEquals('1110480476.1405690517', $provider->extractCookie('GA1.2.1110480476.1405690517')); |
||
35 | $this->assertEquals('286403989.1366364567', $provider->extractCookie('1.2.286403989.1366364567')); |
||
36 | } |
||
37 | } |
||
38 | class ProviderDummy extends ClientIdProvider |
||
50 |