Reset features controller cache in integration tests
[MAILPOET-4207]
This commit is contained in:
@@ -13,7 +13,7 @@ class FeaturesController {
|
||||
self::AUTOMATION => false,
|
||||
];
|
||||
|
||||
/** @var array */
|
||||
/** @var array|null */
|
||||
private $flags;
|
||||
|
||||
/** @var FeatureFlagsRepository */
|
||||
@@ -36,7 +36,7 @@ class FeaturesController {
|
||||
} catch (TableNotFoundException $e) {
|
||||
return $this->defaults[$feature];
|
||||
}
|
||||
return $this->flags[$feature];
|
||||
return ($this->flags ?? [])[$feature];
|
||||
}
|
||||
|
||||
/** @return bool */
|
||||
@@ -52,7 +52,11 @@ class FeaturesController {
|
||||
/** @return array */
|
||||
public function getAllFlags() {
|
||||
$this->ensureFlagsLoaded();
|
||||
return $this->flags;
|
||||
return $this->flags ?? [];
|
||||
}
|
||||
|
||||
public function resetCache(): void {
|
||||
$this->flags = null;
|
||||
}
|
||||
|
||||
private function ensureFlagsLoaded() {
|
||||
|
@@ -3,6 +3,7 @@
|
||||
use MailPoet\Cache\TransientCache;
|
||||
use MailPoet\DI\ContainerWrapper;
|
||||
use MailPoet\Entities\ScheduledTaskEntity;
|
||||
use MailPoet\Features\FeaturesController;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||
@@ -122,7 +123,9 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore
|
||||
$this->diContainer = ContainerWrapper::getInstance(WP_DEBUG);
|
||||
$this->connection = $this->diContainer->get(Connection::class);
|
||||
$this->entityManager = $this->diContainer->get(EntityManager::class);
|
||||
$this->diContainer->get(FeaturesController::class)->resetCache();
|
||||
$this->diContainer->get(SettingsController::class)->resetCache();
|
||||
|
||||
// Cleanup scheduled tasks from previous tests
|
||||
$this->truncateEntity(ScheduledTaskEntity::class);
|
||||
$this->entityManager->clear();
|
||||
|
Reference in New Issue
Block a user