Completed
Push — master ( da1a6c...6bb072 )
by Marco
02:08
created

UnknownPackageFormatTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testVerification() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace RoaveTest\ComposerGpgVerify\Package;
6
7
use Composer\Package\PackageInterface;
8
use PHPUnit\Framework\TestCase;
9
use Roave\ComposerGpgVerify\Package\UnknownPackageFormat;
10
11
/**
12
 * @covers \Roave\ComposerGpgVerify\Package\UnknownPackageFormat
13
 */
14
final class UnknownPackageFormatTest extends TestCase
15
{
16
    public function testVerification() : void
17
    {
18
        /* @var $package PackageInterface|\PHPUnit_Framework_MockObject_MockObject */
19
        $package     = $this->createMock(PackageInterface::class);
20
        $packageName = uniqid('packageName', true);
21
22
        $package->expects(self::any())->method('getName')->willReturn($packageName);
23
24
        $verification = UnknownPackageFormat::fromNonGitPackage($package);
25
26
        self::assertInstanceOf(UnknownPackageFormat::class, $verification);
27
        self::assertSame($packageName, $verification->packageName());
28
        self::assertFalse($verification->isVerified(), 'Unknown package types cannot be verified');
29
        self::assertSame(
30
            'Package "'
31
            . $packageName
32
            . '" is in a format that Roave\ComposerGpgVerify cannot verify:'
33
            . ' try forcing it to be downloaded as GIT repository',
34
            $verification->printReason()
35
        );
36
    }
37
}
38