Skip to content

Commit 1108d2d

Browse files
committed
Level 6
1 parent 1af9cde commit 1108d2d

19 files changed

+117
-59
lines changed

src/VCR/Storage/Blackhole.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ public function key(): int
3333
throw new \BadMethodCallException('Not implemented');
3434
}
3535

36-
public function next(): void
36+
/** @return array<mixed>|null */
37+
public function next(): ?array
3738
{
39+
return null;
3840
}
3941

4042
public function rewind(): void

tests/VCR/CodeTransform/AbstractCodeTransformTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22

33
namespace VCR\CodeTransform;
44

5+
use PHPUnit\Framework\MockObject\MockObject;
56
use PHPUnit\Framework\TestCase;
67

78
class AbstractCodeTransformTest extends TestCase
89
{
10+
/**
11+
* @param string[] $methods
12+
*
13+
* @return AbstractCodeTransform|MockObject
14+
*/
915
protected function getFilter(array $methods = [])
1016
{
1117
$defaults = array_merge(
1218
['transformCode'],
1319
$methods
1420
);
1521

16-
$filter = $this->getMockBuilder('\VCR\CodeTransform\AbstractCodeTransform')
22+
$filter = $this->getMockBuilder(AbstractCodeTransform::class)
1723
->setMethods($defaults)
1824
->getMockForAbstractClass();
1925

tests/VCR/CodeTransform/CurlCodeTransformTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class CurlCodeTransformTest extends TestCase
99
/**
1010
* @dataProvider codeSnippetProvider
1111
*/
12-
public function testTransformCode($expected, $code): void
12+
public function testTransformCode(string $expected, string $code): void
1313
{
1414
$codeTransform = new class() extends CurlCodeTransform {
1515
// A proxy to access the protected transformCode method.
@@ -22,7 +22,8 @@ public function publicTransformCode(string $code): string
2222
$this->assertEquals($expected, $codeTransform->publicTransformCode($code));
2323
}
2424

25-
public function codeSnippetProvider()
25+
/** @return array<string[]> */
26+
public function codeSnippetProvider(): array
2627
{
2728
return [
2829
['\VCR\LibraryHooks\CurlHook::curl_init(', 'CURL_INIT ('],

tests/VCR/CodeTransform/SoapCodeTransformTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class SoapCodeTransformTest extends TestCase
99
/**
1010
* @dataProvider codeSnippetProvider
1111
*/
12-
public function testTransformCode($expected, $code): void
12+
public function testTransformCode(string $expected, string $code): void
1313
{
1414
$codeTransform = new class() extends SoapCodeTransform {
1515
// A proxy to access the protected transformCode method.
@@ -22,7 +22,8 @@ public function publicTransformCode(string $code): string
2222
$this->assertEquals($expected, $codeTransform->publicTransformCode($code));
2323
}
2424

25-
public function codeSnippetProvider()
25+
/** @return array<string[]> */
26+
public function codeSnippetProvider(): array
2627
{
2728
return [
2829
['new \VCR\Util\SoapClient(', 'new \SoapClient('],

tests/VCR/ConfigurationTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ public function testAddRequestMatchers(): void
109109
/**
110110
* @dataProvider availableStorageProvider
111111
*/
112-
public function testSetStorage($name, $className): void
112+
public function testSetStorage(string $name, string $className): void
113113
{
114114
$this->config->setStorage($name);
115115
$this->assertEquals($className, $this->config->getStorage(), "$name should be class $className.");
116116
}
117117

118-
public function availableStorageProvider()
118+
/** @return array<string[]> */
119+
public function availableStorageProvider(): array
119120
{
120121
return [
121122
['json', 'VCR\Storage\Json'],

tests/VCR/LibraryHooks/CurlHookTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
*/
1616
class CurlHookTest extends TestCase
1717
{
18+
/** @var string */
1819
public $expected = 'example response body';
20+
1921
/**
2022
* @var \VCR\Configuration
2123
*/
2224
protected $config;
25+
2326
/**
2427
* @var \VCR\LibraryHooks\CurlHook
2528
*/
@@ -376,7 +379,7 @@ function (Request $request) use ($testClass) {
376379
$this->curlHook->disable();
377380
}
378381

379-
protected function getTestCallback($statusCode = 200): Closure
382+
protected function getTestCallback(string $statusCode = '200'): Closure
380383
{
381384
$testClass = $this;
382385

tests/VCR/LibraryHooks/SoapHookTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ class SoapHookTest extends TestCase
1717
{
1818
public const WSDL = 'https://raw.githubusercontent.com/php-vcr/php-vcr/master/tests/fixtures/soap/wsdl/weather.wsdl';
1919

20+
/** @var string */
2021
public $expected = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetCityWeatherByZIPResponse xmlns="http://ws.cdyne.com/WeatherWS/"><GetCityWeatherByZIPResult><Success>true</Success></GetCityWeatherByZIPResult></GetCityWeatherByZIPResponse></soap:Body></soap:Envelope>';
2122

23+
/** @var Configuration */
2224
protected $config;
2325

2426
/** @var SoapHook */
@@ -104,6 +106,7 @@ protected function getContentCheckCallback(): Closure
104106
});
105107
}
106108

109+
/** @param array<mixed> $expectedHeaders */
107110
protected function getHeadersCheckCallback(array $expectedHeaders): Closure
108111
{
109112
$test = $this;

tests/VCR/Storage/AbstractStorageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
*/
1111
class AbstractStorageTest extends TestCase
1212
{
13-
protected $handle;
14-
protected $filePath;
13+
/** @var TestStorage */
1514
protected $storage;
1615

1716
public function testFilePathCreated(): void
@@ -38,6 +37,7 @@ public function testRootNotExisting(): void
3837

3938
class TestStorage extends AbstractStorage
4039
{
40+
/** @var array<mixed> */
4141
private $recording;
4242

4343
public function storeRecording(array $recording): void

tests/VCR/Storage/BlackholeTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,40 @@
66

77
class BlackholeTest extends TestCase
88
{
9+
/** @var Blackhole */
910
protected $storage;
1011

1112
protected function setUp(): void
1213
{
1314
$this->storage = new Blackhole();
1415
}
1516

17+
/**
18+
* @doesNotPerformAssertions
19+
*/
1620
public function testStoreRecordingIsCallable(): void
1721
{
18-
$this->assertNull($this->storage->storeRecording(['empty or not, we don\'t care']));
22+
$this->storage->storeRecording([
23+
'request' => [
24+
'some' => 'request',
25+
],
26+
'response' => [
27+
'some' => 'response',
28+
],
29+
]);
1930
}
2031

2132
public function testNextIsCallable(): void
2233
{
2334
$this->assertNull($this->storage->next());
2435
}
2536

37+
/**
38+
* @doesNotPerformAssertions
39+
*/
2640
public function testRewindIsCallable(): void
2741
{
28-
$this->assertNull($this->storage->rewind());
42+
$this->storage->rewind();
2943
}
3044

3145
public function testKeyIsNotCallable(): void

tests/VCR/Storage/JsonTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
*/
1111
class JsonTest extends TestCase
1212
{
13-
protected $handle;
13+
/** @var string */
1414
protected $filePath;
15+
16+
/** @var Json */
1517
protected $jsonObject;
1618

1719
protected function setUp(): void
@@ -125,7 +127,8 @@ public function testStoreRecordingWhenBlankFileAlreadyExists(): void
125127
$this->assertJson(file_get_contents($filePath));
126128
}
127129

128-
private function iterateAndTest($json, $expected, $message): void
130+
/** @param array<mixed> $expected */
131+
private function iterateAndTest(string $json, $expected, string $message): void
129132
{
130133
file_put_contents($this->filePath, $json);
131134

0 commit comments

Comments
 (0)