Exemple #1
0
 afterEach(function () {
     Matcher::reset();
     foreach ($this->matchers as $name => $value) {
         foreach ($value as $for => $class) {
             Matcher::register($name, $class, $for);
         }
     }
 });
 describe("::__callStatic()", function () {
     it("creates matcher", function () {
         $arg = Arg::toBe(true);
         expect($arg->match(true))->toBe(true);
         expect($arg->match(true))->not->toBe(false);
     });
     it("creates a negative matcher", function () {
         $arg = Arg::notToBe(true);
         expect($arg->match(true))->not->toBe(true);
         expect($arg->match(true))->toBe(false);
     });
     it("registers a matcher for a specific class", function () {
         Matcher::register('toEqualCustom', Stub::classname(['extends' => 'kahlan\\matcher\\ToEqual']), 'stdClass');
         $arg = Arg::toEqualCustom(new stdClass());
         expect($arg->match(new stdClass()))->toBe(true);
         $arg = Arg::toEqualCustom(new DateTime());
         expect($arg->match(new stdClass()))->not->toBe(true);
     });
     it("makes registered matchers for a specific class available for sub classes", function () {
         Matcher::register('toEqualCustom', Stub::classname(['extends' => 'kahlan\\matcher\\ToEqual']), 'SplHeap');
         $arg = Arg::toEqualCustom(new SplMaxHeap());
         expect($arg->match(new SplMaxHeap()))->toBe(true);
     });