Passed
Pull Request — master (#41)
by Alexander
01:57 queued 36s
created

ResultTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 46
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addErrorIsImmutable() 0 5 1
A isValidByDefault() 0 4 1
A errorsAreEmptyByDefault() 0 4 1
A errorIsProperlyAdded() 0 4 1
A addingErrorChangesIsValid() 0 4 1
1
<?php
2
3
4
namespace Yiisoft\Validator\Tests;
5
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Validator\Result;
9
10
class ResultTest extends TestCase
11
{
12
    /**
13
     * @test
14
     */
15
    public function addErrorIsImmutable(): void
16
    {
17
        $result1 = $result2 = new Result();
18
        $result1 = $result1->addError('Error');
19
        $this->assertNotSame($result1, $result2);
20
    }
21
22
    /**
23
     * @test
24
     */
25
    public function isValidByDefault(): void
26
    {
27
        $result = new Result();
28
        $this->assertTrue($result->isValid());
29
    }
30
31
    /**
32
     * @test
33
     */
34
    public function errorsAreEmptyByDefault(): void
35
    {
36
        $result = new Result();
37
        $this->assertEmpty($result->getErrors());
38
    }
39
40
    /**
41
     * @test
42
     */
43
    public function errorIsProperlyAdded(): void
44
    {
45
        $result = (new Result())->addError('Error');
46
        $this->assertContains('Error', $result->getErrors());
47
    }
48
49
    /**
50
     * @test
51
     */
52
    public function addingErrorChangesIsValid(): void
53
    {
54
        $result = (new Result())->addError('Error');
55
        $this->assertFalse($result->isValid());
56
    }
57
}
58