Exemple #1
0
 });
 $assertion->addProperty('loosely', function () {
     return $this->flag('loosely', true);
 });
 $assertion->addMethod('equal', function ($expected, $message = '') {
     $this->flag('message', $message);
     if ($this->flag('loosely')) {
         return new EqualMatcher($expected);
     }
     return new SameMatcher($expected);
 });
 $assertion->addMethod('throw', function ($exceptionType, $exceptionMessage = '', $message = '') {
     $this->flag('message', $message);
     $matcher = new ExceptionMatcher($exceptionType);
     $matcher->setExpectedMessage($exceptionMessage);
     $matcher->setArguments($this->flag('arguments') ?: []);
     return $matcher;
 });
 $type = function ($expected, $message = '') {
     $this->flag('message', $message);
     return new TypeMatcher($expected);
 };
 $assertion->addMethod('a', $type)->addMethod('an', $type);
 $include = function ($expected, $message = '') {
     $this->flag('message', $message);
     return new InclusionMatcher($expected);
 };
 $assertion->addMethod('include', $include)->addMethod('contain', $include);
 $contain = function () {
     return $this->flag('contain', true);
 };