testFromArrayPreferredInstall()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\ComposerGpgVerify\Exception;
6
7
use InvalidArgumentException;
8
use PHPUnit\Framework\TestCase;
9
use Roave\ComposerGpgVerify\Exception\PreferredInstallIsNotSource;
10
11
/**
12
 * @covers \Roave\ComposerGpgVerify\Exception\PreferredInstallIsNotSource
13
 */
14
final class PreferredInstallIsNotSourceTest extends TestCase
15
{
16
    public function testFromStringPreferredInstall() : void
17
    {
18
        $exception = PreferredInstallIsNotSource::fromPreferredInstall('foo');
19
20
        self::assertInstanceOf(PreferredInstallIsNotSource::class, $exception);
21
        self::assertInstanceOf(InvalidArgumentException::class, $exception);
22
        self::assertSame(
23
            <<<'EXPECTED'
24
The detected preferred install required for the git verification to work correctly is "source", but your composer.json configuration reported "foo".
25
Please edit your composer.json to enforce "source" installation as described at https://getcomposer.org/doc/06-config.md#preferred-install
26
EXPECTED
27
            ,
0 ignored issues
show
Coding Style introduced by
Space found before comma in function call
Loading history...
28
            $exception->getMessage()
29
        );
30
    }
31
    public function testFromArrayPreferredInstall() : void
32
    {
33
        $exception = PreferredInstallIsNotSource::fromPreferredInstall(['foo' => 'bar', 'baz' => 'tab']);
34
35
        self::assertInstanceOf(PreferredInstallIsNotSource::class, $exception);
36
        self::assertInstanceOf(InvalidArgumentException::class, $exception);
37
        self::assertSame(
38
            <<<'EXPECTED'
39
The detected preferred install required for the git verification to work correctly is "source", but your composer.json configuration reported {"foo":"bar","baz":"tab"}.
40
Please edit your composer.json to enforce "source" installation as described at https://getcomposer.org/doc/06-config.md#preferred-install
41
EXPECTED
42
            ,
0 ignored issues
show
Coding Style introduced by
Space found before comma in function call
Loading history...
43
            $exception->getMessage()
44
        );
45
    }
46
}
47