namespace Kahlan\Spec\Suite; use Exception; use RuntimeException; use stdClass; use DateTime; use Kahlan\Specification; use Kahlan\Matcher; use Kahlan\Expectation; use Kahlan\Plugin\Stub; describe("Expectation", function () { beforeEach(function () { $this->matchers = Matcher::get(); }); afterEach(function () { Matcher::reset(); foreach ($this->matchers as $name => $value) { foreach ($value as $for => $class) { Matcher::register($name, $class, $for); } } }); describe("->__call()", function () { it("throws an exception when using an undefined matcher name", function () { $closure = function () { $result = Expectation::expect(true)->toHelloWorld(true); }; expect($closure)->toThrow(new Exception("Unexisting matcher attached to `'toHelloWorld'`.")); }); it("throws an exception when a specific class matcher doesn't match", function () { Matcher::register('toEqualCustom', Stub::classname(['extends' => 'Kahlan\\Matcher\\ToEqual']), 'stdClass');