/** * Run trial callbacks and record their execution state. * * @param \Scientist\Experiment $experiment * * @return \Scientist\Result[] */ protected function runTrials(Experiment $experiment) { $executions = []; foreach ($experiment->getTrials() as $name => $trial) { $executions[$name] = (new Machine($trial, $experiment->getParams(), true))->execute(); } return $executions; }
/** * Run trial callbacks and record their execution state. * * @param \Scientist\Experiment $experiment * @param \Scientist\Execution $control * * @return array */ protected function runTrials(Experiment $experiment, Execution $control) { $executions = []; foreach ($experiment->getTrials() as $name => $trial) { $executions[$name] = $this->executeCallback($trial, $experiment->getParams(), $experiment->getMatcher(), $control); } return $executions; }
public function test_that_multiple_trial_callbacks_can_be_defined() { $e = new Experiment('test experiment'); $first = function () { return 'first'; }; $second = function () { return 'second'; }; $third = function () { return 'third'; }; $e->trial('first', $first); $e->trial('second', $second); $e->trial('third', $third); $expected = ['first' => $first, 'second' => $second, 'third' => $third]; $this->assertSame($expected, $e->getTrials()); }