Beispiel #1
0
 /**
  * @covers Pachico\Abtest\Engine::getTest
  */
 public function testGetTest()
 {
     $this->assertNull($this->object->getTest('foo'));
     $configurator = new Config\Chainable();
     $configurator->addTest('bar', new Split\ArrayProbability([50, 50]));
     $this->object = new Engine($configurator);
     $retrieved_test = $this->object->getTest('bar');
     $this->assertInstanceOf('Pachico\\Abtest\\Test\\Test', $retrieved_test);
     $this->assertSame('bar', $retrieved_test->getName());
 }
Beispiel #2
0
use Pachico\Abtest;
require __DIR__ . '/../vendor/autoload.php';
// Let's store in Redis a key with split to see it running
// Uncomment the following two lines to set them
// $redis = new Abtest\Util\RedisConnector('127.0.0.1');
// $redis->set('ABTESTS:test_key', json_encode([50, 50]));
$abtest_engine = new Abtest\Engine(new Abtest\Config\FromArray(__DIR__ . '/configuration/redis_split.php'));
?>

<html>
	<body style="color: #353535; margin: 30px; font-family: Arial;">
		<h1>Simple test</h1>
		<p>These tests use cookies as Memory. Delete cookies to see these values change.</p>

		<?php 
if ($abtest_engine->getTest('image_test')->isParticipant()) {
    ?>

			<h2>I participate in Image AB test</h2>

			<?php 
    if (0 === $abtest_engine->getTest('image_test')->getVersion()) {
        ?>

				<div>
					<p>This is control version (mountain)</p>
					<img src="https://pixabay.com/static/uploads/photo/2015/11/07/11/45/mountain-lake-1031458_960_720.jpg">
				</div>

			<?php 
    } elseif (1 === $abtest_engine->getTest('image_test')->getVersion()) {
Beispiel #3
0
 */
use Pachico\Abtest;
require __DIR__ . '/../vendor/autoload.php';
$configurator = new Abtest\Config\Chainable(new Abtest\Memory\Cookie('ABTESTS', -1), new Abtest\Tracking\GoogleExperiments(true));
$configurator->addTest('colour', new Abtest\Split\ArrayProbability([50, 50]), null, 'colour_tracking_id');
$configurator->addTest('size', new Abtest\Split\ArrayProbability([50, 50]), null, 'size_tracking_id');
$abtest_engine = new Abtest\Engine($configurator);
?>

<html>
	<body style="color: #353535; margin: 30px; font-family: Arial;">
		<h1>Simple test</h1>
		<p>These tests use cookies as Memory. Delete cookies to see these values change.</p>

		<?php 
if ($abtest_engine->getTest('colour')->isParticipant()) {
    ?>

			<h2>I participate in Colour AB test</h2>

			<?php 
    if (0 === $abtest_engine->getTest('colour')->getVersion()) {
        ?>

				<p style="color: black">This is control version (black)</p>

			<?php 
    } elseif (1 === $abtest_engine->getTest('colour')->getVersion()) {
        ?>

				<p style="color: blue">This is variation 1 (blue)</p>