Exemple #1
0
 public function testResultEvaluatesObservations()
 {
     $a = new Observation('test-a', function () {
         return 1;
     });
     $b = new Observation('test-b', function () {
         return 1;
     });
     $this->assertTrue($a->compare($b));
     $result = new Result(self::$experiment, $a, [$a, $b]);
     $this->assertTrue($result->isMatching());
     $this->assertEquals([], $result->getMismatches());
     $x = new Observation('test-x', function () {
         return 1;
     });
     $y = new Observation('test-y', function () {
         return 2;
     });
     $z = new Observation('test-z', function () {
         return 3;
     });
     $result = new Result(self::$experiment, $x, [$x, $y, $z]);
     $this->assertFalse($result->isMatching());
     $this->assertEquals([$y, $z], $result->getMismatches());
 }
 public function testObservationUsesComparator()
 {
     $a = new Observation('test-a', function () {
         return 1;
     });
     $b = new Observation('test-b', function () {
         return '1';
     });
     $this->assertFalse($a->compare($b));
     $this->assertTrue($a->compare($b, function ($a, $b) {
         return $a == $b;
     }));
 }