Skip to content

Commit

Permalink
Merge pull request #25 from jolelievre/admin-api-renaming
Browse files Browse the repository at this point in the history
Adapt tests to core changes about AdminApi renaming
  • Loading branch information
tleon authored Apr 2, 2024
2 parents 48377a0 + 58fe2ed commit 106cb65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/Integration/ApiPlatform/ApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ abstract class ApiTestCase extends SymfonyApiTestCase
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::updateConfiguration('PS_ADMIN_API_FORCE_DEBUG_SECURED', 0);
ApiClientResetter::resetApiClient();
}

public static function tearDownAfterClass(): void
{
parent::tearDownAfterClass();
ApiClientResetter::resetApiClient();
self::updateConfiguration('PS_ADMIN_API_FORCE_DEBUG_SECURED', 1);
self::$clientSecret = null;
}

Expand Down Expand Up @@ -258,5 +260,6 @@ protected static function addShop(string $shopName, int $shopGroupId, string $co
protected static function updateConfiguration(string $configurationKey, $value, ShopConstraint $shopConstraint = null): void
{
self::getContainer()->get(ShopConfigurationInterface::class)->set($configurationKey, $value, $shopConstraint ?: ShopConstraint::allShops());
\Configuration::resetStaticCache();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public static function setUpBeforeClass(): void
self::$frenchLangId = self::addLanguageByLocale('fr-FR');

self::updateConfiguration(MultistoreConfig::FEATURE_STATUS, 1);
// Disable secure protection for the tests (the configuration reset forced the default config back)
self::updateConfiguration('PS_ADMIN_API_FORCE_DEBUG_SECURED', 0);
self::$secondShopGroupId = self::addShopGroup('Second group');
self::$secondShopId = self::addShop('Second shop', self::DEFAULT_SHOP_GROUP_ID);
self::$thirdShopId = self::addShop('Third shop', self::$secondShopGroupId);
Expand All @@ -81,7 +83,7 @@ public static function setUpBeforeClass(): void
];

$featureFlagManager = self::getContainer()->get('PrestaShop\PrestaShop\Core\FeatureFlag\FeatureFlagManager');
$featureFlagManager->enable(FeatureFlagSettings::FEATURE_FLAG_AUTHORIZATION_SERVER_MULTISTORE);
$featureFlagManager->enable(FeatureFlagSettings::FEATURE_FLAG_ADMIN_API_MULTISTORE);
}

public function getProtectedEndpoints(): iterable
Expand Down
1 change: 0 additions & 1 deletion tests/Integration/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
define('_PS_ROOT_DIR_', dirname(__DIR__, 4));
}
define('_PS_IN_TEST_', true);
define('_PS_API_FORCE_TLS_VERSION_', false);
define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/tests/Resources/modules/');
require_once _PS_ROOT_DIR_ . '/vendor/smarty/smarty/libs/functions.php';
require_once _PS_ROOT_DIR_ . '/admin-dev/bootstrap.php';
Expand Down

0 comments on commit 106cb65

Please sign in to comment.