summaryrefslogtreecommitdiff
path: root/tests/BouncerTest.php
diff options
context:
space:
mode:
authorAsko Nomm <asko@bien.ee>2022-02-22 21:32:37 +0100
committerAsko Nomm <asko@bien.ee>2022-02-22 21:32:37 +0100
commitb0fd14cd71d60c1b9926aff10fe9e8eeebe1285c (patch)
treeff5f1689ffa87a84d8c7487d8a64c885ce7b592e /tests/BouncerTest.php
parent4256c45b6b9c96400b8f372b289be1127495ac56 (diff)
Lots of documentation and basic tests
Diffstat (limited to 'tests/BouncerTest.php')
-rw-r--r--tests/BouncerTest.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/BouncerTest.php b/tests/BouncerTest.php
new file mode 100644
index 0000000..9c14b66
--- /dev/null
+++ b/tests/BouncerTest.php
@@ -0,0 +1,51 @@
+<?php
+
+use Askonomm\Bouncer\Bouncer;
+
+test('Validate a correct e-mail address', function () {
+ $fields = ['email' => 'asko@bien.ee'];
+ $rules = ['email' => 'email'];
+ $bouncer = new Bouncer($fields, $rules);
+
+ expect($bouncer->fails())->toBeFalse();
+});
+
+test('Validate an incorrect e-mail address', function () {
+ $fields = ['email' => 'this-is-not-right'];
+ $rules = ['email' => 'email'];
+ $bouncer = new Bouncer($fields, $rules);
+
+ expect($bouncer->fails())->toBeTrue();
+});
+
+test('Validate a correct length of string', function () {
+ $fields = ['string' => 'i-am-fine-as-i-am-long'];
+ $rules = ['string' => 'len:8'];
+ $bouncer = new Bouncer($fields, $rules);
+
+ expect($bouncer->fails())->toBeFalse();
+});
+
+test('Validate an incorrect length of string', function () {
+ $fields = ['string' => 'i-am-short'];
+ $rules = ['string' => 'len:15'];
+ $bouncer = new Bouncer($fields, $rules);
+
+ expect($bouncer->fails())->toBeTrue();
+});
+
+test('Validate a correct required string', function () {
+ $fields = ['string' => 'i-am-required'];
+ $rules = ['string' => 'required'];
+ $bouncer = new Bouncer($fields, $rules);
+
+ expect($bouncer->fails())->toBeFalse();
+});
+
+test('Validate an incorrect required string', function () {
+ $fields = ['string' => ''];
+ $rules = ['string' => 'required'];
+ $bouncer = new Bouncer($fields, $rules);
+
+ expect($bouncer->fails())->toBeTrue();
+});