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

CheckerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testEmpty() 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 CheckerTest 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' => 'cde'
27
        ], [
28
            'value' => ['my:abc']
29
        ]);
30
31
        $this->assertFalse($v->isValid());
32
        $this->assertSame('Not ABC', $v->getErrors()['value']);
33
34
        /** @var ValidatorInterface $v */
35
        $v = $app->get(ValidationInterface::class)->validate([
36
            'value' => 'abc'
37
        ], [
38
            'value' => ['my:abc']
39
        ]);
40
41
        $this->assertTrue($v->isValid());
42
    }
43
}
44