Passed
Pull Request — master (#69)
by Stephan
01:59
created

AllTest::testWithWildcardIsFalse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Hook\Condition\FileChanged;
13
14
use CaptainHook\App\Console\IO\Mockery as IOMockery;
15
use CaptainHook\App\Mockery as CHMockery;
16
use PHPUnit\Framework\TestCase;
17
18
class AllTest extends TestCase
19
{
20
    use IOMockery;
21
    use CHMockery;
22
23
    /**
24
     * Tests All::isTrue
25
     */
26
    public function testIsFalse(): void
27
    {
28
        $io = $this->createIOMock();
29
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
30
        $operator   = $this->createGitDiffOperator(['fiz.php', 'baz.php', 'foo.php']);
31
        $repository = $this->createRepositoryMock('');
32
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
33
34
        $fileChange = new All(['foo.php', 'bar.php']);
35
36
        $this->assertFalse($fileChange->isTrue($io, $repository));
37
    }
38
39
    /**
40
     * Tests All::isTrue
41
     */
42
    public function testWithWildcardIsFalse(): void
43
    {
44
        $io = $this->createIOMock();
45
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
46
        $operator   = $this->createGitDiffOperator(['fiz.php', 'baz.php', 'foo.php']);
47
        $repository = $this->createRepositoryMock('');
48
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
49
50
        $fileChange = new All(['foo.*', 'bar.php']);
51
52
        $this->assertFalse($fileChange->isTrue($io, $repository));
53
    }
54
55
    /**
56
     * Tests All::isTrue
57
     */
58
    public function testIsTrue(): void
59
    {
60
        $io = $this->createIOMock();
61
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
62
        $operator   = $this->createGitDiffOperator(['foo.php', 'bar.php', 'baz.php']);
63
        $repository = $this->createRepositoryMock('');
64
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
65
66
        $fileChange = new All(['foo.php', 'bar.php']);
67
68
        $this->assertTrue($fileChange->isTrue($io, $repository));
69
    }
70
71
    /**
72
     * Tests All::isTrue
73
     */
74
    public function testWithWildcardIsTrue(): void
75
    {
76
        $io = $this->createIOMock();
77
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
78
        $operator   = $this->createGitDiffOperator(['foo.php', 'bar.php', 'baz.php']);
79
        $repository = $this->createRepositoryMock('');
80
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
81
82
        $fileChange = new All(['foo.*', 'ba?.php']);
83
84
        $this->assertTrue($fileChange->isTrue($io, $repository));
85
    }
86
}
87