예제 #1
0
                return $chain->next($message);
            });
            expect(Filter::registered('spec.newclosure'))->toBe(true);
        });
        it("registers a closure with no name", function () {
            $name = Filter::register(function ($chain, $message) {
                $message = "My {$message}";
                return $chain->next($message);
            });
            expect(Filter::registered($name))->toBe(true);
        });
    });
    describe("::unregister()", function () {
        it("unregisters a closure", function () {
            Filter::register('spec.newclosure', function ($chain, $message) {
                $message = "My {$message}";
                return $chain->next($message);
            });
            Filter::unregister('spec.newclosure');
            expect(Filter::registered('spec.newclosure'))->toBe(false);
        });
    });
    describe("::resets()", function () {
        it("clears all the filters", function () {
            Filter::reset();
            expect(Filter::registered('spec.my_prefix'))->toBe(false);
            expect(Filter::registered('spec.be_prefix'))->toBe(false);
            expect(Filter::registered('spec.no_chain'))->toBe(false);
        });
    });
});