|
13 | 13 |
|
14 | 14 | class SecurityIssuesTest extends ApiTestCase
|
15 | 15 | {
|
16 |
| - public function testAll() |
| 16 | + public function testAll(): void |
17 | 17 | {
|
18 | 18 | $expected = [
|
19 | 19 | [
|
@@ -41,7 +41,7 @@ public function testAll()
|
41 | 41 | $this->assertSame($expected, $api->all());
|
42 | 42 | }
|
43 | 43 |
|
44 |
| - public function testAllWithFilters() |
| 44 | + public function testAllWithFilters(): void |
45 | 45 | {
|
46 | 46 | $expected = [
|
47 | 47 | [
|
@@ -73,7 +73,85 @@ public function testAllWithFilters()
|
73 | 73 | $this->assertSame($expected, $api->all($filters));
|
74 | 74 | }
|
75 | 75 |
|
76 |
| - protected function getApiClass() |
| 76 | + public function testShow(): void |
| 77 | + { |
| 78 | + $expected = [ |
| 79 | + 'packageName' => 'acme-website/package', |
| 80 | + 'state' => 'open', |
| 81 | + 'branch' => 'dev-master', |
| 82 | + 'installedPackage' => 'acme/library', |
| 83 | + 'installedVersion' => '1.0.0', |
| 84 | + 'advisory' => [ |
| 85 | + 'title' => 'CVE-1999: Remote code execution', |
| 86 | + 'link' =>'https://acme.website/security-advisories', |
| 87 | + 'cve' => 'CVE-1999', |
| 88 | + 'affectedVersions' => '>=1.0', |
| 89 | + ], |
| 90 | + ]; |
| 91 | + |
| 92 | + /** @var SecurityIssues&MockObject $api */ |
| 93 | + $api = $this->getApiMock(); |
| 94 | + $api->expects($this->once()) |
| 95 | + ->method('get') |
| 96 | + ->with($this->equalTo('/security-issues/12')) |
| 97 | + ->willReturn($expected); |
| 98 | + |
| 99 | + $this->assertSame($expected, $api->show(12)); |
| 100 | + } |
| 101 | + |
| 102 | + public function testOpen(): void |
| 103 | + { |
| 104 | + $expected = [ |
| 105 | + 'packageName' => 'acme-website/package', |
| 106 | + 'state' => 'open', |
| 107 | + 'branch' => 'dev-master', |
| 108 | + 'installedPackage' => 'acme/library', |
| 109 | + 'installedVersion' => '1.0.0', |
| 110 | + 'advisory' => [ |
| 111 | + 'title' => 'CVE-1999: Remote code execution', |
| 112 | + 'link' =>'https://acme.website/security-advisories', |
| 113 | + 'cve' => 'CVE-1999', |
| 114 | + 'affectedVersions' => '>=1.0', |
| 115 | + ], |
| 116 | + ]; |
| 117 | + |
| 118 | + /** @var SecurityIssues&MockObject $api */ |
| 119 | + $api = $this->getApiMock(); |
| 120 | + $api->expects($this->once()) |
| 121 | + ->method('post') |
| 122 | + ->with($this->equalTo('/security-issues/12/open')) |
| 123 | + ->willReturn($expected); |
| 124 | + |
| 125 | + $this->assertSame($expected, $api->open(12)); |
| 126 | + } |
| 127 | + |
| 128 | + public function testClose(): void |
| 129 | + { |
| 130 | + $expected = [ |
| 131 | + 'packageName' => 'acme-website/package', |
| 132 | + 'state' => SecurityIssues::STATE_IN_PROGRESS, |
| 133 | + 'branch' => 'dev-master', |
| 134 | + 'installedPackage' => 'acme/library', |
| 135 | + 'installedVersion' => '1.0.0', |
| 136 | + 'advisory' => [ |
| 137 | + 'title' => 'CVE-1999: Remote code execution', |
| 138 | + 'link' =>'https://acme.website/security-advisories', |
| 139 | + 'cve' => 'CVE-1999', |
| 140 | + 'affectedVersions' => '>=1.0', |
| 141 | + ], |
| 142 | + ]; |
| 143 | + |
| 144 | + /** @var SecurityIssues&MockObject $api */ |
| 145 | + $api = $this->getApiMock(); |
| 146 | + $api->expects($this->once()) |
| 147 | + ->method('post') |
| 148 | + ->with($this->equalTo('/security-issues/12/close/' . SecurityIssues::STATE_IN_PROGRESS)) |
| 149 | + ->willReturn($expected); |
| 150 | + |
| 151 | + $this->assertSame($expected, $api->close(12, SecurityIssues::STATE_IN_PROGRESS)); |
| 152 | + } |
| 153 | + |
| 154 | + protected function getApiClass(): string |
77 | 155 | {
|
78 | 156 | return SecurityIssues::class;
|
79 | 157 | }
|
|
0 commit comments