Passed
Push — master ( 7c61fd...4bc778 )
by Sebastian
02:04
created

StagedFilesTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 15
c 1
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testOfType() 0 11 1
A testCustomSeparator() 0 10 1
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\Runner\Action\Cli\Command\Placeholder;
13
14
use CaptainHook\App\Mockery as AppMockery;
15
use PHPUnit\Framework\TestCase;
16
17
class StagedFilesTest extends TestCase
18
{
19
    use AppMockery;
20
21
    /**
22
     * Tests StagedFiles::replacement
23
     */
24
    public function testCustomSeparator(): void
25
    {
26
        $repo  = $this->createRepositoryMock();
27
        $index = $this->createGitIndexOperator(['file1.php', 'file2.php', 'README.md']);
28
        $repo->expects($this->once())->method('getIndexOperator')->willReturn($index);
29
30
        $placeholder = new StagedFiles($repo);
31
        $command     = $placeholder->replacement(['separated-by' => ', ']);
32
33
        $this->assertEquals('file1.php, file2.php, README.md', $command);
34
    }
35
36
    /**
37
     * Tests StagedFiles::replacement
38
     */
39
    public function testOfType(): void
40
    {
41
        $repo  = $this->createRepositoryMock();
42
        $index = $this->createGitIndexOperator(['file1.php', 'file2.php', 'README.md']);
43
        $repo->expects($this->once())->method('getIndexOperator')->willReturn($index);
44
        $index->expects($this->once())->method('getStagedFilesOfType')->willReturn(['file1.php', 'file2.php']);
45
46
        $placeholder = new StagedFiles($repo);
47
        $command     = $placeholder->replacement(['of-type' => 'php']);
48
49
        $this->assertEquals('file1.php file2.php', $command);
50
    }
51
}
52