kahlan\Matcher::reset PHP Метод

reset() публичный статический Метод

Resets the class.
public static reset ( )
    public static function reset()
    {
        static::$_matchers = [];
    }

Usage Example

Пример #1
0
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');