-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathInternTest.php
60 lines (54 loc) · 1.99 KB
/
InternTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
use Scientist\Intern;
use Scientist\Report;
use Scientist\Experiment;
use Scientist\Laboratory;
class InternTest extends \PHPUnit\Framework\TestCase
{
public function test_that_intern_can_be_created()
{
$i = new Intern;
$this->assertInstanceOf(Intern::class, $i);
}
public function test_that_intern_can_run_an_experiment()
{
$i = new Intern;
$e = new Experiment('test experiment', new Laboratory);
$e->control(function () { return 'foo'; });
$v = $i->run($e);
$this->assertInstanceOf(Report::class, $v);
$this->assertEquals('foo', $v->getControl()->getValue());
}
public function test_that_intern_can_match_control_and_trial()
{
$i = new Intern;
$e = new Experiment('test experiment', new Laboratory);
$e->control(function () { return 'foo'; });
$e->trial('bar', function () { return 'foo'; });
$v = $i->run($e);
$this->assertInstanceOf(Report::class, $v);
$this->assertTrue($v->getTrial('bar')->isMatch());
}
public function test_that_intern_can_mismatch_control_and_trial()
{
$i = new Intern;
$e = new Experiment('test experiment', new Laboratory);
$e->control(function () { return 'foo'; });
$e->trial('bar', function () { return 'bar'; });
$v = $i->run($e);
$this->assertInstanceOf(Report::class, $v);
$this->assertFalse($v->getTrial('bar')->isMatch());
}
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(Report::class, $v);
$this->assertTrue($v->getTrial('bar')->isMatch());
$this->assertFalse($v->getTrial('baz')->isMatch());
}
}