BinaryTest::testSuccess()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ComposerRequireCheckerTest;
4
5
use function implode;
6
use PHPUnit\Framework\TestCase;
7
8
final class BinaryTest extends TestCase
9
{
10
    /** @var string */
11
    private $bin;
12
13
    protected function setUp(): void
14
    {
15
        if (strpos(\PHP_OS, "WIN") === 0) {
16
            $this->bin = __DIR__ . "\\..\\..\\bin\\composer-require-checker.bat";
17
        } else {
18
            $this->bin = __DIR__ . "/../../bin/composer-require-checker";
19
        }
20
    }
21
22
    public function testSuccess(): void
23
    {
24
        exec($this->bin, $output, $return);
25
        $this->assertSame(0, $return);
26
    }
27
28
    public function testUnknownSymbols(): void
29
    {
30
        $path = __DIR__ . "/../fixtures/unknownSymbols/composer.json";
31
        exec("{$this->bin} check {$path} 2>&1", $output, $return);
32
        $this->assertSame(1, $return);
33
        $this->assertStringContainsString("The following unknown symbols were found", implode("\n", $output));
34
    }
35
36
    public function testInvalidConfiguration(): void
37
    {
38
        $path = __DIR__ . "/../fixtures/validJson.json";
39
        exec("{$this->bin} check {$path} 2>&1", $output, $return);
40
        $this->assertSame(1, $return);
41
        $this->assertStringContainsString("dependencies have not been installed", implode("\n", $output));
42
    }
43
}
44