1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace RoaveTest\ComposerGpgVerify\Exception; |
6
|
|
|
|
7
|
|
|
use LogicException; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use Roave\ComposerGpgVerify\Exception\PackagesTrustCheckFailed; |
10
|
|
|
use Roave\ComposerGpgVerify\Package\PackageVerification; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @covers \Roave\ComposerGpgVerify\Exception\PackagesTrustCheckFailed |
14
|
|
|
*/ |
15
|
|
|
final class PackagesTrustCheckFailedTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
public function testFromFailedPackageVerificationsWithSinglePackage() : void |
18
|
|
|
{ |
19
|
|
|
/* @var $verification PackageVerification|\PHPUnit_Framework_MockObject_MockObject */ |
20
|
|
|
$verification = $this->createMock(PackageVerification::class); |
21
|
|
|
|
22
|
|
|
$verification->expects(self::any())->method('printReason')->willReturn('foo'); |
|
|
|
|
23
|
|
|
|
24
|
|
|
$exception = PackagesTrustCheckFailed::fromFailedPackageVerifications($verification); |
25
|
|
|
|
26
|
|
|
self::assertInstanceOf(PackagesTrustCheckFailed::class, $exception); |
27
|
|
|
self::assertInstanceOf(LogicException::class, $exception); |
28
|
|
|
self::assertSame( |
29
|
|
|
<<<'EXPECTED' |
30
|
|
|
The following packages need to be signed and verified, or added to exclusions: |
31
|
|
|
foo |
32
|
|
|
EXPECTED |
33
|
|
|
, |
34
|
|
|
$exception->getMessage() |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testFromFailedPackageVerificationsWithMultiplePackages() : void |
39
|
|
|
{ |
40
|
|
|
/* @var $verification1 PackageVerification|\PHPUnit_Framework_MockObject_MockObject */ |
41
|
|
|
$verification1 = $this->createMock(PackageVerification::class); |
42
|
|
|
/* @var $verification2 PackageVerification|\PHPUnit_Framework_MockObject_MockObject */ |
43
|
|
|
$verification2 = $this->createMock(PackageVerification::class); |
44
|
|
|
/* @var $verification3 PackageVerification|\PHPUnit_Framework_MockObject_MockObject */ |
45
|
|
|
$verification3 = $this->createMock(PackageVerification::class); |
46
|
|
|
|
47
|
|
|
$verification1->expects(self::any())->method('printReason')->willReturn('foo'); |
|
|
|
|
48
|
|
|
$verification2->expects(self::any())->method('printReason')->willReturn('bar'); |
|
|
|
|
49
|
|
|
$verification3->expects(self::any())->method('printReason')->willReturn('baz'); |
|
|
|
|
50
|
|
|
|
51
|
|
|
$exception = PackagesTrustCheckFailed::fromFailedPackageVerifications( |
52
|
|
|
$verification1, |
53
|
|
|
$verification2, |
54
|
|
|
$verification3 |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
self::assertInstanceOf(PackagesTrustCheckFailed::class, $exception); |
58
|
|
|
self::assertInstanceOf(LogicException::class, $exception); |
59
|
|
|
self::assertSame( |
60
|
|
|
<<<'EXPECTED' |
61
|
|
|
The following packages need to be signed and verified, or added to exclusions: |
62
|
|
|
foo |
63
|
|
|
|
64
|
|
|
bar |
65
|
|
|
|
66
|
|
|
baz |
67
|
|
|
EXPECTED |
68
|
|
|
, |
69
|
|
|
$exception->getMessage() |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.