control() public method

Register a control callback.
public control ( callable $callback )
$callback callable
 public function test_that_running_experiment_with_no_laboratory_executes_control()
 {
     $e = new Experiment('test experiment');
     $e->control(function () {
         return 'foo';
     });
     $v = $e->run();
     $this->assertEquals('foo', $v);
 }
 public function test_that_a_control_callback_can_be_defined()
 {
     $e = new Experiment('test experiment');
     $control = function () {
         return true;
     };
     $e->control($control);
     $this->assertSame($control, $e->getControl());
 }
Example #3
0
 public function test_that_intern_can_match_and_mismatch_control_and_trial()
 {
     $i = new Intern();
     $e = new Experiment('test experiment', new Laboratory());
     $e->control(function () {
         return 'foo';
     });
     $e->trial('bar', function () {
         return 'foo';
     });
     $e->trial('baz', function () {
         return 'baz';
     });
     $v = $i->run($e);
     $this->assertInstanceOf('\\Scientist\\Report', $v);
     $this->assertTrue($v->getTrial('bar')->isMatch());
     $this->assertFalse($v->getTrial('baz')->isMatch());
 }