summaryrefslogtreecommitdiff
path: root/tests/BouncerTest.php
blob: 9c14b66937f521cf8707c325eb975ca8ad6e51ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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();
});