Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Documentation #1

Open
vassilevsky opened this issue Jul 31, 2011 · 5 comments
Open

Documentation #1

vassilevsky opened this issue Jul 31, 2011 · 5 comments

Comments

@vassilevsky
Copy link

Where can one find at least an example of how to use this?

@arnaudlimbourg
Copy link

Documentation would be a huge plus

@dcampano
Copy link

dcampano commented Sep 8, 2011

Would also love to see some documentation

@StefanKarpinski
Copy link

+1

1 similar comment
@lyrixx
Copy link

lyrixx commented Oct 15, 2011

+1

@oscarspaz
Copy link

A very rough attempt to use the library.

//Testing Scripts
include('AB2/Test.php');
include('AB2/Variant.php');
include('AB2/VariantUtils.php');
include('AB2/SubjectIDProvider/PHPSessionID.php');

//Loggers
include('AB2/Logger.php');
include('AB2/Logger/TestVarMap.php');
include('AB2/Logger/UniqueEntries.php');

//Implemented Selectors
include('AB2/Selector/Fixed.php');
include('AB2/Selector/Sequence.php');
include('AB2/Selector/Weighted.php');

//Implemented Randomizers
include('AB2/Selector/Random.php');
include('AB2/Selector/HashRandomizer.php');

$ab2_name = "Test001";
$ab2_logger = new AB2_Logger_TestVarMap();
$ab2_subjectIDProvider = new AB2_PHPSessionID();

//Weights and Properties
$ws = array('button_blue'=>30,'button_green'=>70);
$ps = array('button_blue'=>array('color'=>'#0000ff'),'button_green'=>array('color'=>'#00ff00'));

//Build An Array of Variants
$variants = AB2_VariantUtils::buildVariants($ws, $ps);

//Random Randomizer
$ab_rndzer = new AB2_Selector_Random();

//Hash Randomizer
//$ab_hash_rndzer = new AB2_Selector_HashRandomizer($ab2_name);

//$ab2_sf = new AB2_Selector_Fixed('button_blue');
$ab2_sw = new AB2_Selector_Weighted($ws, $ab_rndzer );

//Create the test
$ab2_test = new AB2_Test($ab2_name, $variants, $ab2_sw, $ab2_subjectIDProvider, $ab2_logger);

//Select a variant using the weighted Selector
$variant_selected = $ab2_test->select();
$props = $variant_selected->getProperties();
if (($variant_selected->getName())=="button_blue"){
printf("Show Blue Button",$props["color"]);
} elseif (($variant_selected->getName())=="button_green"){
printf("Show Green Button",$props["color"]);
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants