Skip to content

Commit 5221599

Browse files
authored
Add attribute check to subscriber (#9)
* Updated to accept vcr attribute * Updated readme usage example * Added check on test prepared
1 parent b34f655 commit 5221599

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Subscribers/OnTestPrepared.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,13 @@ public function getCassette(Test $test, string $tag = '@vcr'): ?string
5050
}
5151

5252
$reflection = new \ReflectionMethod($class, $method);
53-
$docblock = $reflection->getDocComment();
5453

54+
$attributes = $reflection->getAttributes(\VCR\PHPUnit\TestListener\Attributes\Vcr::class);
55+
if (!empty($attributes)) {
56+
return $attributes[0]->getArguments()[0];
57+
}
58+
59+
$docblock = $reflection->getDocComment();
5560
if (!empty($docblock)) {
5661
$parsed = self::parseDocBlock($docblock, $tag);
5762
return array_pop($parsed);

0 commit comments

Comments
 (0)