PreferredInstallIsNotSourceTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFromStringPreferredInstall() 0 15 1
A testFromArrayPreferredInstall() 0 15 1
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