$closure = function () use($class) {
Filter::apply($class, 'filterable', 'spec.unexisting_closure');
};
expect($closure)->toThrow(new Exception('Undefined filter `spec.unexisting_closure`.'));
});
});
describe("::filters()", function () {
it("exports filters setted as a class level", function () {
Filter::apply($this->class, 'filterable', 'spec.my_prefix');
$filters = Filter::filters();
expect($filters)->toHaveLength(1);
expect(isset($filters[$this->class]))->toBe(true);
});
it("imports class based filters", function () {
Filter::filters([$this->class => [Filter::registered('spec.my_prefix')]]);
$filters = Filter::filters();
expect($filters)->toHaveLength(1);
expect(isset($filters[$this->class]))->toBe(true);
});
});
});
describe("::apply()", function () {
it("throws an Exception when trying to apply a filter on an unfilterable context", function () {
$closure = function () {
Filter::apply(null, 'filterable', 'spec.my_prefix');
};
expect($closure)->toThrow(new Exception("Error this context can't be filtered."));
});
});
describe("::registered()", function () {
it("exports the `Filter` class data", function () {