Exemple #1
0
     it("checks url values", function () {
         expect(Checker::is('url', 'http://example.com'))->toBe(true);
         expect(Checker::is('url', 'http://www.domain.com/super?param=value'))->toBe(true);
         expect(Checker::is('url', 'http:/example.com'))->toBe(false);
     });
     it("checks uuid values", function () {
         expect(Checker::is('uuid', '1c0a5830-6025-11de-8a39-0800200c9a66'))->toBe(true);
         expect(Checker::is('uuid', '1c0a5831-6025-11de-8a39-0800200c9a66'))->toBe(true);
         expect(Checker::is('uuid', '1c0a5832-6025-11de-8a39-0800200c9a66'))->toBe(true);
         expect(Checker::is('uuid', 'zc0a5832-6025-11de-8a39-0800200c9a66'))->toBe(false);
         expect(Checker::is('uuid', '1-1c0a5832-6025-11de-8a39-0800200c9a66'))->toBe(false);
     });
     it("checks the not option", function () {
         expect(Checker::is('inList', 'one', ['list' => ['one', 'two']]))->toBe(true);
         expect(Checker::is('not:inList', 'one', ['list' => ['one', 'two']]))->toBe(false);
         expect(Checker::isNotInList('one', ['list' => ['one', 'two']]))->toBe(false);
     });
 });
 describe("::__callStatic()", function () {
     it("delegates to the checker", function () {
         $handler = Checker::get('alphaNumeric');
         expect(Checker::class)->toReceive('::check')->with('frferrf', [$handler], ['hello' => 'world']);
         Checker::isAlphaNumeric('frferrf', ['hello' => 'world']);
     });
     it("bails out with no passed parameters", function () {
         expect(Checker::isAlphaNumeric())->toBe(false);
     });
 });
 describe("::message()", function () {
     it("gets a error message", function () {
         expect(Checker::message('required'))->toBe('is required');