The Laboratory is where the magic takes place. Here we define and conduct our experiments.
コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: LaboratoryTest.php プロジェクト: vantoozz/scientist
 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());
 }
コード例 #3
0
ファイル: JournalTest.php プロジェクト: vantoozz/scientist
 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());
 }
コード例 #4
0
 /**
  * Execute the experiment and return a report.
  *
  * @return \Scientist\Report
  */
 public function report()
 {
     $this->params = func_get_args();
     return $this->laboratory->getReport($this);
 }