faker->word(); $validator = Validator::make( [$attribute => $this->faker->boolean()], [$attribute => new IsValidBoolean()] ); static::assertTrue($validator->passes()); } /** * The Is Valid Boolean Rule shall return true if "true" or "false" is provided. * * @return void */ public function testPassesIfBooleanString(): void { $booleanString = $this->faker->boolean() ? 'true' : 'false'; $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => $booleanString], [$attribute => new IsValidBoolean()] ); static::assertTrue($validator->passes()); } /** * The Is Valid Boolean Rule shall return true if 1 or 0 is provided. * * @return void */ public function testPassesIfBooleanInteger(): void { $booleanInteger = $this->faker->boolean() ? 1 : 0; $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => $booleanInteger], [$attribute => new IsValidBoolean()] ); static::assertTrue($validator->passes()); } /** * The Is Valid Boolean Rule shall return true if "on" or "off" is provided. * * @return void */ public function testPassesIfBooleanCheckbox(): void { $booleanCheckbox = $this->faker->boolean() ? 'on' : 'off'; $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => $booleanCheckbox], [$attribute => new IsValidBoolean()] ); static::assertTrue($validator->passes()); } /** * The Is Valid Boolean Rule shall return false a string is provided. * * @return void */ public function testFailsIfString(): void { $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => $this->faker->word()], [$attribute => new IsValidBoolean()] ); static::assertFalse($validator->passes()); } /** * The Is Valid Boolean Rule shall return false a number is provided. * * @return void */ public function testFailsIfNumber(): void { $attribute = $this->faker->word(); $validator = Validator::make( [$attribute => $this->faker->numberBetween(2, 9)], [$attribute => new IsValidBoolean()] ); static::assertFalse($validator->passes()); } }