Example #1
0
     });
     it("applies all filter set on the classname", function () {
         Filter::apply(get_class($this->mock), 'filterable', 'spec.my_prefix');
         expect($this->mock->filterable('World!'))->toBe('Hello My World!');
     });
     it("throws an Exception when trying to apply a filter using an unexisting closure", function () {
         $closure = function () {
             Filter::apply($this->mock, 'filterable', 'spec.unexisting_closure');
         };
         expect($closure)->toThrow(new Exception('Undefined filter `spec.unexisting_closure`.'));
     });
 });
 describe("::detach()", function () {
     it("detaches a filters", function () {
         Filter::apply($this->mock, 'filterable', 'spec.my_prefix');
         Filter::detach($this->mock, 'filterable', 'spec.my_prefix');
         expect($this->mock->filterable('World!'))->toBe('Hello World!');
     });
 });
 describe("::filters()", function () {
     it("gets filters of a context", function () {
         Filter::apply($this->mock, 'filterable', 'spec.my_prefix');
         $filters = Filter::filters($this->mock, 'filterable');
         expect($filters)->toBeAn('array')->toHaveLength(1);
         expect(reset($filters))->toBeAnInstanceOf('Closure');
     });
 });
 describe("::enable()", function () {
     it("disables the filter system", function () {
         Filter::apply($this->mock, 'filterable', 'spec.my_prefix');
         Filter::enable(false);