From 49caddb2c1eeb2c49742f12d5dc6cf0e248da74f Mon Sep 17 00:00:00 2001 From: Astrid Blanco Date: Wed, 2 Oct 2024 08:00:20 +1000 Subject: [PATCH] Added check on test prepared --- src/Subscribers/OnTestPrepared.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Subscribers/OnTestPrepared.php b/src/Subscribers/OnTestPrepared.php index 89a3667..2d748ba 100644 --- a/src/Subscribers/OnTestPrepared.php +++ b/src/Subscribers/OnTestPrepared.php @@ -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);