Passed
Pull Request — master (#277)
by Kirill
03:11
created

AliasTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testEmpty() 0 22 1
A testAliased() 0 22 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Framework\Validation;
13
14
use Spiral\Tests\Framework\BaseTest;
15
use Spiral\Validation\ValidationInterface;
16
use Spiral\Validation\ValidatorInterface;
17
18
class AliasTest extends BaseTest
19
{
20
    public function testEmpty(): void
21
    {
22
        $app = $this->makeApp();
23
24
        /** @var ValidatorInterface $v */
25
        $v = $app->get(ValidationInterface::class)->validate([
26
            'value' => ''
27
        ], [
28
            'value' => ['notEmpty']
29
        ]);
30
31
        $this->assertFalse($v->isValid());
32
33
34
        /** @var ValidatorInterface $v */
35
        $v = $app->get(ValidationInterface::class)->validate([
36
            'value' => 'abc'
37
        ], [
38
            'value' => ['notEmpty']
39
        ]);
40
41
        $this->assertTrue($v->isValid());
42
    }
43
44
    public function testAliased(): void
45
    {
46
        $app = $this->makeApp();
47
48
        /** @var ValidatorInterface $v */
49
        $v = $app->get(ValidationInterface::class)->validate([
50
            'value' => ''
51
        ], [
52
            'value' => ['aliased']
53
        ]);
54
55
        $this->assertFalse($v->isValid());
56
57
58
        /** @var ValidatorInterface $v */
59
        $v = $app->get(ValidationInterface::class)->validate([
60
            'value' => 'abc'
61
        ], [
62
            'value' => ['aliased']
63
        ]);
64
65
        $this->assertTrue($v->isValid());
66
    }
67
}
68