}); describe("->set()", function () { it("sets some local handlers", function () { $validator = new Validator(); $validator->set('zeroToNine', '/^[0-9]$/'); $validator->set('tenToNineteen', '/^1[0-9]$/'); expect($validator->has('zeroToNine'))->toBe(true); expect($validator->has('tenToNineteen'))->toBe(true); expect($validator->get('zeroToNine'))->toBe('/^[0-9]$/'); expect($validator->get('tenToNineteen'))->toBe('/^1[0-9]$/'); }); it("overrides handlers", function () { $validator = new Validator(); $validator->set('zeroToNine', '/^[0-5]$/'); $validator->set('zeroToNine', '/^[0-9]$/'); expect($validator->get('zeroToNine'))->toBe('/^[0-9]$/'); }); }); describe("->handlers()", function () { beforeEach(function () { Checker::reset(true); $this->validator = new Validator(); $this->validator->set('zeroToNine', '/^[0-9]$/'); }); it("gets some handlers", function () { expect($this->validator->handlers())->toBe(['zeroToNine' => '/^[0-9]$/']); }); it("appends some handlers", function () { $expected = ['zeroToNine' => '/^[0-9]$/', 'tenToNineteen' => '/^1[0-9]$/']; expect($this->validator->handlers(['tenToNineteen' => '/^1[0-9]$/']))->toBe($expected); expect($this->validator->handlers())->toBe($expected);