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