Use Codeception\TestInterface::getName() instead of Codeception\TestInterface::getMetadata()

This commit changes the code to use $event->getTest()->getName() instead
of $event->getTest()->getMetadata()->getName() to get the name of the
current test. This was necessary because the latter was returning null
for integration tests while the former works both for acceptance and
integration tests. I did not investigate why Codeception behaves this
way due to lack of time, there is a chance that this is a bug in
Codeception.

Since $event->getTest() returns an instance of TestInterface and this
class does not define getName() (but the call works probably due to some
magic method), it was necessary to edit phpstan.neon to skip a PHPStan
error.

[MAILPOET-4765]
This commit is contained in:
Rodrigo Primo
2022-11-03 15:38:31 -03:00
committed by Rostislav Wolný
parent 713b0255f7
commit ea16472ab1
2 changed files with 5 additions and 1 deletions

View File

@ -74,6 +74,10 @@ parameters:
message: '/^Cannot call method get\(\) on mixed.$/'
count: 1
path: ../../lib/PostEditorBlocks/WooCommerceBlocksIntegration.php
-
message: '/^Call to an undefined method Codeception\\TestInterface::getName()./'
count: 1
path: ../../tests/_support/CheckSkippedTestsExtension.php
reportUnmatchedIgnoredErrors: true
dynamicConstantNames:
- MAILPOET_PREMIUM_INITIALIZED

View File

@ -12,7 +12,7 @@ class CheckSkippedTestsExtension extends Extension {
public function checkSkippedTests(FailEvent $event) {
$branch = getenv('CIRCLE_BRANCH');
$testName = $event->getTest()->getMetadata()->getName();
$testName = $event->getTest()->getName();
// list of tests that are allowed to be skipped on trunk and release branches
$allowedToSkipList = [