Skip to content

Commit a02bb57

Browse files
committed
Level 1
1 parent 3eeecb0 commit a02bb57

File tree

7 files changed

+30
-25
lines changed

7 files changed

+30
-25
lines changed

src/VCR/VCR.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* @method static void turnOn()
1313
* @method static void turnOff()
1414
* @method static void eject()
15+
* @mixin Videorecorder
1516
*/
1617
class VCR
1718
{
@@ -37,7 +38,7 @@ class VCR
3738
*/
3839
public static function __callStatic(string $method, array $parameters)
3940
{
40-
$callable = [VCRFactory::get('VCR\Videorecorder'), $method];
41+
$callable = [VCRFactory::get(Videorecorder::class), $method];
4142

4243
Assertion::isCallable($callable);
4344

tests/VCR/ConfigurationTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ protected function setUp(): void
1818

1919
public function testSetCassettePathThrowsErrorOnInvalidPath(): void
2020
{
21-
$this->expectException(
22-
VCRException::class,
21+
$this->expectException(VCRException::class);
22+
$this->expectExceptionMessage(
2323
"Cassette path 'invalid_path' is not a directory. Please either "
2424
.'create it or set a different cassette path using '
2525
."\\VCR\\VCR::configure()->setCassettePath('directory')."
@@ -63,7 +63,8 @@ public function testEnableSingleLibraryHook(): void
6363

6464
public function testEnableLibraryHooksFailsWithWrongHookName(): void
6565
{
66-
$this->expectException('InvalidArgumentException', "Library hooks don't exist: non_existing");
66+
$this->expectException(\InvalidArgumentException::class);
67+
$this->expectExceptionMessage("Library hooks don't exist: non_existing");
6768
$this->config->enableLibraryHooks(['non_existing']);
6869
}
6970

@@ -81,13 +82,15 @@ public function testEnableRequestMatchers(): void
8182

8283
public function testEnableRequestMatchersFailsWithNoExistingName(): void
8384
{
84-
$this->expectException('InvalidArgumentException', "Request matchers don't exist: wrong, name");
85+
$this->expectException(\InvalidArgumentException::class);
86+
$this->expectExceptionMessage("Request matchers don't exist: wrong, name");
8587
$this->config->enableRequestMatchers(['wrong', 'name']);
8688
}
8789

8890
public function testAddRequestMatcherFailsWithNoName(): void
8991
{
90-
$this->expectException('VCR\VCRException', "A request matchers name must be at least one character long. Found ''");
92+
$this->expectException(\VCR\VCRException::class);
93+
$this->expectExceptionMessage("A request matchers name must be at least one character long. Found ''");
9194
$expected = function ($first, $second) {
9295
return true;
9396
};
@@ -122,7 +125,8 @@ public function availableStorageProvider()
122125

123126
public function testSetStorageInvalidName(): void
124127
{
125-
$this->expectException('VCR\VCRException', "Storage 'Does not exist' not available.");
128+
$this->expectException(\VCR\VCRException::class);
129+
$this->expectExceptionMessage("Storage 'Does not exist' not available.");
126130
$this->config->setStorage('Does not exist');
127131
}
128132

@@ -154,7 +158,8 @@ public function testBlacklist(): void
154158

155159
public function testSetModeInvalidName(): void
156160
{
157-
$this->expectException('VCR\VCRException', "Mode 'invalid' does not exist.");
161+
$this->expectException(\VCR\VCRException::class);
162+
$this->expectExceptionMessage("Mode 'invalid' does not exist.");
158163
$this->config->setMode('invalid');
159164
}
160165
}

tests/VCR/RequestTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,8 @@ public function testDoesntMatch(): void
6262
public function testMatchesThrowsExceptionIfMatcherNotFound(): void
6363
{
6464
$request = new Request('POST', 'http://example.com', ['User-Agent' => 'Unit-Test']);
65-
$this->expectException(
66-
'\BadFunctionCallException',
67-
"Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n"
68-
);
65+
$this->expectException(\BadFunctionCallException::class);
66+
$this->expectExceptionMessage("Matcher could not be executed. Array\n(\n [0] => some\n [1] => method\n)\n");
6967
$this->request->matches($request, [['some', 'method']]);
7068
}
7169

tests/VCR/Storage/AbstractStorageTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public function testFilePathCreated(): void
2828

2929
public function testRootNotExisting(): void
3030
{
31-
$this->expectException('\VCR\VCRException', "Cassette path 'vfs://test/foo' is not existing or not a directory");
31+
$this->expectException(\VCR\VCRException::class);
32+
$this->expectExceptionMessage("Cassette path 'vfs://test/foo' is not existing or not a directory");
3233

3334
vfsStream::setup('test');
3435
new TestStorage(vfsStream::url('test/foo'), 'file');

tests/VCR/Util/CurlHelperTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,15 @@ public function testSetCurlOptionReadFunctionToNull(): void
165165

166166
public function testInvalidHostException(): void
167167
{
168-
$this->expectException(InvalidHostException::class, 'URL must be valid.');
168+
$this->expectException(InvalidHostException::class);
169+
$this->expectExceptionMessage('Could not read host from URL "example.com". Please check the URL syntax.');
169170
new Request('POST', 'example.com');
170171
}
171172

172173
public function testSetCurlOptionReadFunctionMissingSize(): void
173174
{
174-
$this->expectException('\VCR\VCRException', 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.');
175+
$this->expectException(\VCR\VCRException::class);
176+
$this->expectExceptionMessage('To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.');
175177
$request = new Request('POST', 'http://example.com');
176178

177179
$callback = function ($curlHandle, $fileHandle, $size): void {

tests/VCR/VCRTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ public static function setupBeforeClass(): void
2222
public function testUseStaticCallsNotInitialized(): void
2323
{
2424
VCR::configure()->enableLibraryHooks(['stream_wrapper']);
25-
$this->expectException(
26-
'VCR\VCRException',
27-
'Please turn on VCR before inserting a cassette, use: VCR::turnOn()'
28-
);
25+
$this->expectException(\VCR\VCRException::class);
26+
$this->expectExceptionMessage('Please turn on VCR before inserting a cassette, use: VCR::turnOn()');
2927
VCR::insertCassette('some_name');
3028
}
3129

@@ -103,8 +101,8 @@ public function testShouldNotInterceptCallsToDevUrandom(): void
103101

104102
public function testShouldThrowExceptionIfNoCassettePresent(): void
105103
{
106-
$this->expectException(
107-
'BadMethodCallException',
104+
$this->expectException(\BadMethodCallException::class);
105+
$this->expectExceptionMessage(
108106
'Invalid http request. No cassette inserted. Please make sure to insert '
109107
."a cassette in your unit test using VCR::insertCassette('name');"
110108
);

tests/VCR/VideorecorderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function setCassette(Cassette $cassette): void
6161

6262
public function testHandleRequestThrowsExceptionWhenModeIsNone(): void
6363
{
64-
$this->expectException(
65-
'LogicException',
64+
$this->expectException(\LogicException::class);
65+
$this->expectExceptionMessage(
6666
"The request does not match a previously recorded request and the 'mode' is set to 'none'. "
6767
."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'."
6868
);
@@ -109,8 +109,8 @@ public function setCassette(Cassette $cassette): void
109109

110110
public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld(): void
111111
{
112-
$this->expectException(
113-
'LogicException',
112+
$this->expectException(\LogicException::class);
113+
$this->expectExceptionMessage(
114114
"The request does not match a previously recorded request and the 'mode' is set to 'once'. "
115115
."If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'."
116116
);

0 commit comments

Comments
 (0)