From dfe0351124dfd3c0acf26205668ab5b69351bbd9 Mon Sep 17 00:00:00 2001 From: Asko Nomm Date: Tue, 22 Feb 2022 21:55:37 +0100 Subject: Improvements --- tests/BouncerTest.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/BouncerTest.php b/tests/BouncerTest.php index 9c14b66..473b476 100644 --- a/tests/BouncerTest.php +++ b/tests/BouncerTest.php @@ -15,7 +15,9 @@ test('Validate an incorrect e-mail address', function () { $rules = ['email' => 'email']; $bouncer = new Bouncer($fields, $rules); - expect($bouncer->fails())->toBeTrue(); + expect($bouncer->errors())->toBe([ + 'email is not a valid e-mail address.' + ]); }); test('Validate a correct length of string', function () { @@ -31,7 +33,9 @@ test('Validate an incorrect length of string', function () { $rules = ['string' => 'len:15']; $bouncer = new Bouncer($fields, $rules); - expect($bouncer->fails())->toBeTrue(); + expect($bouncer->errors())->toBe([ + 'string is shorter than the required 15 characters.' + ]); }); test('Validate a correct required string', function () { @@ -43,9 +47,22 @@ test('Validate a correct required string', function () { }); test('Validate an incorrect required string', function () { - $fields = ['string' => '']; - $rules = ['string' => 'required']; + $fields = [ + 'empty-string' => '', + 'null-value' => null, + 'false-value' => false, + ]; + + $rules = [ + 'empty-string' => 'required', + 'null-value' => 'required', + 'false-value' => 'required', + ]; + $bouncer = new Bouncer($fields, $rules); - expect($bouncer->fails())->toBeTrue(); + expect($bouncer->errors())->toBe([ + 'empty-string is required.', + 'null-value is required.', + ]); }); -- cgit v1.2.3