StdInTest::testStdInValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 9.9666
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
    public function testStdInValue(): void
26
    {
27
        $expected = 'refs/heads/main 9dfa0fa6221d75f48b2dfac359127324bedf8409'
28
                  . ' refs/heads/main 8309f6e16097754469c485e604900c573bf2c5d8';
29
30
        $io     = $this->createIOMock();
31
        $repo   = $this->createRepositoryMock();
32
        $config = $this->createConfigMock();
33
        $io->expects($this->once())->method('getStandardInput')->willReturn([$expected]);
34
35
        $placeholder = new StdIn($io, $config, $repo);
36
        $result      = $placeholder->replacement([]);
37
38
        $this->assertEquals(escapeshellarg($expected), $result);
39
    }
40
41
    public function testEmptyStdIn(): void
42
    {
43
        $io     = $this->createIOMock();
44
        $repo   = $this->createRepositoryMock();
45
        $config = $this->createConfigMock();
46
        $io->method('getStandardInput')->willReturn([]);
47
48
        $placeholder = new StdIn($io, $config, $repo);
49
        $result      = $placeholder->replacement([]);
50
        $this->assertEquals("''", $result);
51
    }
52
}
53