Exemplo n.º 1
0
 public function testRegisterConversionAddsToLeverNumeratorAndPersists()
 {
     $l = \MaBandit\Lever::forValue('test');
     $l->incrementDenominator();
     $this->assertEquals(0, $l->getNumerator());
     $bandit = $this->getBandit();
     $bandit->registerConversion($l);
     $this->assertEquals(1, $l->getNumerator());
     $f = new \MaBandit\Persistence\PersistedLever('test', '');
     $this->assertEquals($l, $bandit->getPersistor()->loadLever($f));
 }
 public function testLoadsLeversForExperiment()
 {
     $p = new \MaBandit\Persistence\ArrayPersistor();
     $l = \MaBandit\Lever::forValue('x')->inflate(new \MaBandit\Persistence\PersistedLever('foo', 'y', 1, 2));
     $l1 = \MaBandit\Lever::forValue('x')->inflate(new \MaBandit\Persistence\PersistedLever('bar', 'y', 3, 4));
     $p->saveLever($l);
     $p->saveLever($l1);
     $f = new \MaBandit\Persistence\PersistedLever('we', 'y');
     $actual = $p->loadLeversForExperiment($f);
     $expected = array('foo' => $l, 'bar' => $l1);
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 3
0
 /**
  * @expectedException \MaBandit\Exception\LeverNumeratorTooHighException
  */
 public function testIncrementNumeratorRaisesIf100PercentConversionRate()
 {
     $l = \MaBandit\Lever::forValue('foo');
     $l->incrementNumerator();
 }