Files
piratepoet/mailpoet/tests/_support/CheckSkippedTestsExtension.php
2024-05-03 10:55:53 +02:00

35 lines
1.3 KiB
PHP

<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
use Codeception\Event\FailEvent;
use Codeception\Events;
use Codeception\Extension;
// phpcs:ignore PSR1.Classes.ClassDeclaration
class CheckSkippedTestsExtension extends Extension {
public static $events = [
Events::TEST_SKIPPED => 'checkSkippedTests',
];
public function checkSkippedTests(FailEvent $event) {
$branch = getenv('CIRCLE_BRANCH');
$testName = $event->getTest()->getName();
// list of tests that are allowed to be skipped on trunk and release branches
$allowedToSkipList = [
'createSubscriptionSegmentForActiveSubscriptions',
'testAllSubscribersFoundWithOperatorAny',
'testAllSubscribersFoundWithOperatorNoneOf',
'testAllSubscribersFoundWithOperatorAllOf',
'automationTriggeredByRegistrationWitConfirmationNeeded',
'automationTriggeredByRegistrationWithoutConfirmationNeeded',
// The next two tests can be removed after dropping support for WP 6.4
'createAndSendStandardNewsletter',
'displayNewsletterPreview',
];
if (in_array($branch, ['trunk', 'release']) && !in_array($testName, $allowedToSkipList)) {
throw new \PHPUnit\Framework\ExpectationFailedException("Failed, cannot skip tests on branch $branch.");
}
}
}