Passed
Pull Request — master (#41)
by Alexander
10:28
created

ResultTest::errorsAreEmptyByDefault()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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