Passed
Push — main ( c1e8d7...13f864 )
by Sebastian
03:58
created

ConfigurationTest::testConfigFailure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9
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\Console\Command;
13
14
use CaptainHook\App\Console\IO\NullIO;
15
use CaptainHook\App\Console\Runtime\Resolver;
16
use Symfony\Component\Console\Input\ArrayInput;
17
use Symfony\Component\Console\Output\NullOutput;
18
use PHPUnit\Framework\TestCase;
19
use Symfony\Component\Console\Output\OutputInterface;
20
21
class ConfigurationTest extends TestCase
22
{
23
    /**
24
     * Tests Configure::run
25
     *
26
     * @throws \Exception
27
     */
28
    public function testExecute(): void
29
    {
30
        $resolver  = new Resolver();
31
        $config    = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(mt_rand(0, 9999)) . '.json';
32
        $output    = new NullOutput();
33
        $input     = new ArrayInput(['--configuration' => $config]);
34
35
        $configure = new Configuration($resolver);
36
        $configure->setIO(new NullIO());
37
        $configure->run($input, $output);
38
39
        $this->assertFileExists($config);
40
41
        unlink($config);
42
    }
43
44
    /**
45
     * Tests Configure::run
46
     *
47
     * @throws \Exception
48
     */
49
    public function testConfigFailure(): void
50
    {
51
        $resolver  = new Resolver();
52
        $config    = '/foo/bar/fiz/baz/config.json';
53
        $input     = new ArrayInput(['--configuration' => $config]);
54
        $output    = $this->getMockBuilder(OutputInterface::class)
55
                          ->disableOriginalConstructor()
56
                          ->getMock();
57
        $output->method('isVerbose')->willReturn(true);
58
59
        $configure = new Configuration($resolver);
60
        $configure->setIO(new NullIO());
61
        $code = $configure->run($input, $output);
62
63
        $this->assertEquals(1, $code);
64
    }
65
}
66