trial() публичный Метод

Register a trial callback.
public trial ( string $name, callable $callback )
$name string
$callback callable
Пример #1
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());
 }
Пример #2
0
 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());
 }