public function testGetParticipations()
 {
     // Arrange
     $data = ['walter' => 1, 'bernard' => 0];
     $gaRenderer = new GoogleUniversalAnalytics($data);
     // Act
     $returnedData = $gaRenderer->getParticipations();
     // Assert
     $this->assertSame($data, $returnedData);
 }
Example #2
0
// Create a Participation filter
$filter = new Percentage(50);
// And a Variant Chooser
$chooser = new RandomChooser();
// Create the Engine
$engine = new Engine($manager, $dispatcher, $filter, $chooser);
// Create a tests and its variants
$test = new Test('foo_test', [], [Google::EXPERIMENT_ID => 'exp1']);
$test->addVariant(new SimpleVariant('_control'));
$test->addVariant(new SimpleVariant('_variant1'));
$test->addVariant(new SimpleVariant('_variant2'));
// Create a second test and its variants
$test2 = new Test('bar_test', [], [Google::EXPERIMENT_ID => 'exp2']);
$test2->addVariant(new SimpleVariant('_control'));
$test2->addVariant(new SimpleVariant('_variant1'));
$test2->addVariant(new SimpleVariant('_variant2'));
// Add the tests to the Engine
$engine->addTest($test);
$engine->addTest($test2);
// Pseudo: if($user->isAdmin)
// If the user is admin, he should not participate at the test
// $manager->participate('foo_test', null);
// Pseudo: if($app->inDevelopment() and $_GET['phpab']['foo_test])
// $manager->participate('foo_test', $_GET['phpab']['foo_test]);
// Start testing. Must occur before the EventCycle of the app starts
// Start the engine
$engine->start();
// Create the Analytics object and pass the Data Collector data to it
$analytics = new GoogleUniversalAnalytics($analyticsData->getTestsData());
// Execute the Analytics functionality
var_dump($analytics->getScript());