Skip to content

Commit

Permalink
Fixed flickery issues with tests. (#10054)
Browse files Browse the repository at this point in the history
Fixed flickery issues with tests.
  • Loading branch information
a-sabaa authored May 5, 2023
1 parent 943052c commit 15f14d4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/SprykerTest/Zed/Locale/_support/Helper/LocaleDataHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use Generated\Shared\Transfer\LocaleTransfer;
use Orm\Zed\Locale\Persistence\SpyLocaleStoreQuery;
use Orm\Zed\Store\Persistence\SpyStoreQuery;
use ReflectionClass;
use Spryker\Zed\Locale\Business\Cache\LocaleCache;
use Spryker\Zed\Locale\Business\LocaleFacadeInterface;
use SprykerTest\Shared\Testify\Helper\LocatorHelperTrait;

Expand All @@ -34,6 +36,8 @@ public function haveLocale(array $seedData = []): LocaleTransfer
$localeTransfer = $this->generateLocaleTransfer($seedData);

if ($this->getLocaleFacade()->hasLocale($localeTransfer->getLocaleName())) {
$this->resetLocaleCacheClass();

return $this->getLocaleFacade()->getLocale($localeTransfer->getLocaleName());
}

Expand Down Expand Up @@ -168,4 +172,19 @@ protected function generateLocaleTransfer(array $seedData = [])

return $localeTransfer;
}

/**
* @return void
*/
protected function resetLocaleCacheClass(): void
{
$class = new ReflectionClass(LocaleCache::class);
$localeCache = $class->getProperty('localeCache');
$localeCache->setAccessible(true);
$localeCache->setValue([]);

$localeCacheById = $class->getProperty('localeCacheById');
$localeCacheById->setAccessible(true);
$localeCacheById->setValue([]);
}
}

0 comments on commit 15f14d4

Please sign in to comment.