public function test_that_running_experiment_with_zero_chance_executes_control() { $l = new Laboratory(); $v = $l->experiment('test experiment')->control(function () { return 'foo'; })->chance(0)->run(); $this->assertEquals('foo', $v); }
public function test_that_control_and_trials_receive_parameters() { $laboratory = new Laboratory(); $r = $laboratory->experiment('test experiment')->control(function ($one, $two) { return $one; })->trial('trial', function ($one, $two) { return $two; })->report('Panda', 'Giraffe'); $this->assertInstanceOf('\\Scientist\\Report', $r); $this->assertEquals('Panda', $r->getControl()->getValue()); $this->assertEquals('Giraffe', $r->getTrial('trial')->getValue()); }
public function test_that_journal_receives_result_information() { $lab = new Laboratory(); $journal = new StandardJournal(); $lab->addJournal($journal); $control = function () { return 'foo'; }; $trial = function () { return 'bar'; }; $value = $lab->experiment('foo')->control($control)->trial('bar', $trial)->run(); $this->assertEquals('foo', $value); $this->assertInstanceOf('\\Scientist\\Report', $journal->getReport()); $this->assertEquals('foo', $journal->getReport()->getName()); $this->assertEquals('foo', $journal->getReport()->getControl()->getValue()); $this->assertEquals('bar', $journal->getReport()->getTrial('bar')->getValue()); $this->assertEquals(false, $journal->getReport()->getTrial('bar')->isMatch()); }
/** * Execute the experiment and return a report. * * @return \Scientist\Report */ public function report() { $this->params = func_get_args(); return $this->laboratory->getReport($this); }