From ab9c1a2b1bed8c3013144730f4c764ed4a81c4e6 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Thu, 1 Aug 2024 10:05:39 +1000 Subject: [PATCH] use method name to eliminate method not found warnings --- composer.json | 6 ++---- src/Subscribers/OnTestPrepared.php | 6 +++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index cf44d52..c342158 100644 --- a/composer.json +++ b/composer.json @@ -20,9 +20,7 @@ }, "require": { "covergenius/php-vcr": "^1.7", - "php": "^8.1" - }, - "require-dev": { - "phpunit/phpunit": "^10.1" + "php": "^8.1", + "phpunit/phpunit": "^10.4" } } diff --git a/src/Subscribers/OnTestPrepared.php b/src/Subscribers/OnTestPrepared.php index d53691e..89a3667 100644 --- a/src/Subscribers/OnTestPrepared.php +++ b/src/Subscribers/OnTestPrepared.php @@ -43,7 +43,11 @@ public function getCassette(Test $test, string $tag = '@vcr'): ?string { $reflection = new \ReflectionClass($test); $class = $reflection->getProperty('className')->getValue($test); - $method = $test->name(); + if ($test instanceof Event\Code\TestMethod) { + $method = $test->methodName(); + } else { + $method = $test->name(); + } $reflection = new \ReflectionMethod($class, $method); $docblock = $reflection->getDocComment();