Skip to content

Commit

Permalink
Add attribute check to subscriber (#9)
Browse files Browse the repository at this point in the history
* Updated to accept vcr attribute

* Updated readme usage example

* Added check on test prepared
  • Loading branch information
cg-x authored Oct 2, 2024
1 parent b34f655 commit 5221599
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Subscribers/OnTestPrepared.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ public function getCassette(Test $test, string $tag = '@vcr'): ?string
}

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

$attributes = $reflection->getAttributes(\VCR\PHPUnit\TestListener\Attributes\Vcr::class);
if (!empty($attributes)) {
return $attributes[0]->getArguments()[0];
}

$docblock = $reflection->getDocComment();
if (!empty($docblock)) {
$parsed = self::parseDocBlock($docblock, $tag);
return array_pop($parsed);
Expand Down

0 comments on commit 5221599

Please sign in to comment.