Completed
Push — master ( 17598f...abee1f )
by Kirill
13s queued 11s
created

ConditionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testEmpty() 0 32 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 ConditionTest 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' => [
29
                [
30
                    'my:abc',
31
                    'if' => 'cond'
32
                ]
33
            ]
34
        ]);
35
36
        $this->assertTrue($v->isValid());
37
38
        /** @var ValidatorInterface $v */
39
        $v = $app->get(ValidationInterface::class)->validate([
40
            'value' => 'value'
41
        ], [
42
            'value' => [
43
                [
44
                    'my:abc',
45
                    'if' => 'cond'
46
                ]
47
            ]
48
        ]);
49
50
        $this->assertFalse($v->isValid());
51
        $this->assertSame('Not ABC', $v->getErrors()['value']);
52
    }
53
}
54