StdInTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testStdInValue() 0 14 1
A testEmptyStdIn() 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\Console\IO\Mockery as IOMockery;
15
use CaptainHook\App\Config\Mockery as ConfigMockery;
16
use CaptainHook\App\Mockery as AppMockery;
17
use PHPUnit\Framework\TestCase;
18
19
class StdInTest extends TestCase
20
{
21
    use IOMockery;
22
    use AppMockery;
23
    use ConfigMockery;
24
25
    /**
26
     * Tests StdIn::replacement
27
     */
28
    public function testStdInValue(): void
29
    {
30
        $expected = 'refs/heads/main 9dfa0fa6221d75f48b2dfac359127324bedf8409'
31
                  . ' refs/heads/main 8309f6e16097754469c485e604900c573bf2c5d8';
32
33
        $io     = $this->createIOMock();
34
        $repo   = $this->createRepositoryMock();
35
        $config = $this->createConfigMock();
36
        $io->expects($this->once())->method('getStandardInput')->willReturn([$expected]);
37
38
        $placeholder = new StdIn($io, $config, $repo);
39
        $result      = $placeholder->replacement([]);
40
41
        $this->assertEquals(escapeshellarg($expected), $result);
42
    }
43
44
    /**
45
     * Tests StdIn::replacement
46
     */
47
    public function testEmptyStdIn(): void
48
    {
49
        $io     = $this->createIOMock();
50
        $repo   = $this->createRepositoryMock();
51
        $config = $this->createConfigMock();
52
        $io->method('getStandardInput')->willReturn([]);
53
54
        $placeholder = new StdIn($io, $config, $repo);
55
        $result      = $placeholder->replacement([]);
56
        $this->assertEquals("''", $result);
57
    }
58
}
59