Skip to content

Commit

Permalink
added client id tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Rieger committed Jan 3, 2015
1 parent b4b4d3b commit 1dc6ed8
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/Racecore/GATracking/GATrackingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
*/
class GATrackingTest extends AbstractGATrackingTest
{
public function setUp()
{
$_COOKIE = array();
}

public function setDown()
{
$_COOKIE = null;
}

public function testInstanceIsGenerated()
{
$service = new GATracking('fooId');
Expand All @@ -32,6 +42,46 @@ public function testAnalyticsAccountIdCanBeSet()
$this->assertEquals('newFoo', $service->getAnalyticsAccountUid());
}

public function testClientIdCanSet()
{
$service = new GATracking('foo');
$service->setOption('client_id', 'foo');
$this->assertEquals('foo', $service->getClientId());
}

public function testClientIdCanSetOverCookieOldUuid()
{
$service = new GATracking('foo');
$_COOKIE['_ga'] = 'foo.bar.baz.quux';

$this->assertEquals('baz.quux', $service->getClientId());
}

public function testClientIdCanSetOverCookieNewUuid()
{
$service = new GATracking('foo');
$_COOKIE['_ga'] = 'foo.bar.f9f0b1fe-8d57-4adb-babc-787fd873613c';

$this->assertEquals('f9f0b1fe-8d57-4adb-babc-787fd873613c', $service->getClientId());
}

public function testClientIdGetGenerated()
{
$service = new GATracking('foo');
$service->setOption('client_create_random_id', true);

$this->assertNotNull($service->getClientId());
}

public function testClientIdFallback()
{
$service = new GATracking('foo');
$service->setOption('client_create_random_id', false);
$service->setOption('client_fallback_id', 'foo');

$this->assertEquals('foo', $service->getClientId());
}

public function testSetUpClientAdapterFromConstructor()
{
$service = new GATracking('fooId');
Expand Down

0 comments on commit 1dc6ed8

Please sign in to comment.