AllTest::testWithWildcardIsFalse()   A
last analyzed

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
    public function testIsFalse(): void
24
    {
25
        $io = $this->createIOMock();
26
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
27
        $operator   = $this->createGitDiffOperator(['fiz.php', 'baz.php', 'foo.php']);
28
        $repository = $this->createRepositoryMock('');
29
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
30
31
        $fileChange = new All(['foo.php', 'bar.php'], '');
32
33
        $this->assertFalse($fileChange->isTrue($io, $repository));
34
    }
35
36
    public function testWithWildcardIsFalse(): void
37
    {
38
        $io = $this->createIOMock();
39
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
40
        $operator   = $this->createGitDiffOperator(['fiz.php', 'baz.php', 'foo.php']);
41
        $repository = $this->createRepositoryMock('');
42
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
43
44
        $fileChange = new All(['foo.*', 'bar.php']);
45
46
        $this->assertFalse($fileChange->isTrue($io, $repository));
47
    }
48
49
    public function testIsTrue(): void
50
    {
51
        $io = $this->createIOMock();
52
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
53
        $operator   = $this->createGitDiffOperator(['foo.php', 'bar.php', 'baz.php']);
54
        $repository = $this->createRepositoryMock('');
55
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
56
57
        $fileChange = new All(['foo.php', 'bar.php']);
58
59
        $this->assertTrue($fileChange->isTrue($io, $repository));
60
    }
61
62
    public function testWithWildcardIsTrue(): void
63
    {
64
        $io = $this->createIOMock();
65
        $io->expects($this->exactly(2))->method('getArgument')->willReturn('');
66
        $operator   = $this->createGitDiffOperator(['foo.php', 'bar.php', 'baz.php']);
67
        $repository = $this->createRepositoryMock('');
68
        $repository->expects($this->once())->method('getDiffOperator')->willReturn($operator);
69
70
        $fileChange = new All(['foo.*', 'ba?.php']);
71
72
        $this->assertTrue($fileChange->isTrue($io, $repository));
73
    }
74
}
75