diff --git a/tests/Integration/ApiPlatform/CustomerGroupApiTest.php b/tests/Integration/ApiPlatform/CustomerGroupApiTest.php index e984f49..2147616 100644 --- a/tests/Integration/ApiPlatform/CustomerGroupApiTest.php +++ b/tests/Integration/ApiPlatform/CustomerGroupApiTest.php @@ -73,7 +73,7 @@ public function testAddCustomerGroup(): int 'auth_bearer' => $bearerToken, 'json' => [ 'localizedNames' => [ - 1 => 'test1', + 'en-US' => 'test1', ], 'reductionPercent' => 10.3, 'displayPriceTaxExcluded' => true, @@ -92,7 +92,7 @@ public function testAddCustomerGroup(): int [ 'customerGroupId' => $customerGroupId, 'localizedNames' => [ - 1 => 'test1', + 'en-US' => 'test1', ], 'reductionPercent' => 10.3, 'displayPriceTaxExcluded' => true, @@ -114,7 +114,7 @@ public function testAddCustomerGroupWithoutShopIds(): int 'auth_bearer' => $bearerToken, 'json' => [ 'localizedNames' => [ - 1 => 'test1', + 'en-US' => 'test1', ], 'reductionPercent' => 10.3, 'displayPriceTaxExcluded' => true, @@ -132,7 +132,7 @@ public function testAddCustomerGroupWithoutShopIds(): int [ 'customerGroupId' => $customerGroupId, 'localizedNames' => [ - 1 => 'test1', + 'en-US' => 'test1', ], 'reductionPercent' => 10.3, 'displayPriceTaxExcluded' => true, @@ -162,7 +162,7 @@ public function testUpdateCustomerGroup(int $customerGroupId): int 'auth_bearer' => $bearerToken, 'json' => [ 'localizedNames' => [ - 1 => 'new_test1', + 'en-US' => 'new_test1', ], 'displayPriceTaxExcluded' => false, 'shopIds' => [1], @@ -179,7 +179,7 @@ public function testUpdateCustomerGroup(int $customerGroupId): int [ 'customerGroupId' => $customerGroupId, 'localizedNames' => [ - 1 => 'new_test1', + 'en-US' => 'new_test1', ], 'reductionPercent' => 10.3, 'displayPriceTaxExcluded' => false, @@ -214,7 +214,7 @@ public function testGetCustomerGroup(int $customerGroupId): int [ 'customerGroupId' => $customerGroupId, 'localizedNames' => [ - 1 => 'new_test1', + 'en-US' => 'new_test1', ], 'reductionPercent' => 10.3, 'displayPriceTaxExcluded' => false, diff --git a/tests/Integration/ApiPlatform/ProductEndpointTest.php b/tests/Integration/ApiPlatform/ProductEndpointTest.php index bb51ec7..523936e 100644 --- a/tests/Integration/ApiPlatform/ProductEndpointTest.php +++ b/tests/Integration/ApiPlatform/ProductEndpointTest.php @@ -33,16 +33,13 @@ class ProductEndpointTest extends ApiTestCase { - protected const EN_LANG_ID = 1; - protected static int $frenchLangId; - public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); (new ResourceResetter())->backupTestModules(); ProductResetter::resetProducts(); LanguageResetter::resetLanguages(); - self::$frenchLangId = self::addLanguageByLocale('fr-FR'); + self::addLanguageByLocale('fr-FR'); self::createApiClient(['product_write', 'product_read']); } @@ -110,8 +107,8 @@ public function testAddProduct(): int 'json' => [ 'type' => ProductType::TYPE_STANDARD, 'names' => [ - self::EN_LANG_ID => 'product name', - self::$frenchLangId => 'nom produit', + 'en-US' => 'product name', + 'fr-FR' => 'nom produit', ], ], ]); @@ -128,12 +125,12 @@ public function testAddProduct(): int 'type' => ProductType::TYPE_STANDARD, 'productId' => $productId, 'names' => [ - self::EN_LANG_ID => 'product name', - self::$frenchLangId => 'nom produit', + 'en-US' => 'product name', + 'fr-FR' => 'nom produit', ], 'descriptions' => [ - self::EN_LANG_ID => '', - self::$frenchLangId => '', + 'en-US' => '', + 'fr-FR' => '', ], 'active' => false, ], @@ -163,10 +160,10 @@ public function testPartialUpdateProduct(int $productId): int ], 'json' => [ 'names' => [ - self::$frenchLangId => 'nouveau nom', + 'fr-FR' => 'nouveau nom', ], 'descriptions' => [ - self::EN_LANG_ID => 'new description', + 'en-US' => 'new description', ], 'active' => true, ], @@ -183,12 +180,12 @@ public function testPartialUpdateProduct(int $productId): int 'type' => ProductType::TYPE_STANDARD, 'productId' => $productId, 'names' => [ - self::EN_LANG_ID => 'product name', - self::$frenchLangId => 'nouveau nom', + 'en-US' => 'product name', + 'fr-FR' => 'nouveau nom', ], 'descriptions' => [ - self::EN_LANG_ID => 'new description', - self::$frenchLangId => '', + 'en-US' => 'new description', + 'fr-FR' => '', ], 'active' => true, ], @@ -203,7 +200,7 @@ public function testPartialUpdateProduct(int $productId): int ], 'json' => [ 'names' => [ - self::EN_LANG_ID => 'new product name', + 'en-US' => 'new product name', ], ], ]); @@ -216,12 +213,12 @@ public function testPartialUpdateProduct(int $productId): int 'type' => ProductType::TYPE_STANDARD, 'productId' => $productId, 'names' => [ - self::EN_LANG_ID => 'new product name', - self::$frenchLangId => 'nouveau nom', + 'en-US' => 'new product name', + 'fr-FR' => 'nouveau nom', ], 'descriptions' => [ - self::EN_LANG_ID => 'new description', - self::$frenchLangId => '', + 'en-US' => 'new description', + 'fr-FR' => '', ], 'active' => true, ], @@ -252,12 +249,12 @@ public function testGetProduct(int $productId): int 'type' => ProductType::TYPE_STANDARD, 'productId' => $productId, 'names' => [ - self::EN_LANG_ID => 'new product name', - self::$frenchLangId => 'nouveau nom', + 'en-US' => 'new product name', + 'fr-FR' => 'nouveau nom', ], 'descriptions' => [ - self::EN_LANG_ID => 'new description', - self::$frenchLangId => '', + 'en-US' => 'new description', + 'fr-FR' => '', ], 'active' => true, ], @@ -302,8 +299,8 @@ public function testAddImage(int $productId): int $this->assertMatchesRegularExpression('@/img/p[/0-9]+/' . $imageId . '-small_default\.jpg@', $decodedResponse['thumbnailUrl']); $this->assertArrayHasKey('legends', $decodedResponse); $this->assertEquals([ - self::EN_LANG_ID => '', - self::$frenchLangId => '', + 'en-US' => '', + 'fr-FR' => '', ], $decodedResponse['legends']); $this->assertArrayHasKey('cover', $decodedResponse); $this->assertIsBool($decodedResponse['cover']); @@ -337,8 +334,8 @@ public function testGetImage(int $imageId): string $this->assertMatchesRegularExpression('@/img/p[/0-9]+/' . $imageId . '-small_default\.jpg@', $decodedResponse['thumbnailUrl']); $this->assertArrayHasKey('legends', $decodedResponse); $this->assertEquals([ - self::EN_LANG_ID => '', - self::$frenchLangId => '', + 'en-US' => '', + 'fr-FR' => '', ], $decodedResponse['legends']); $this->assertArrayHasKey('cover', $decodedResponse); $this->assertIsBool($decodedResponse['cover']); @@ -369,8 +366,8 @@ public function testUpdateImage(int $imageId, string $imageMD5): int 'extra' => [ 'parameters' => [ 'legends' => [ - self::EN_LANG_ID => 'legend en', - self::$frenchLangId => 'legend fr', + 'en-US' => 'legend en', + 'fr-FR' => 'legend fr', ], ], 'files' => [ @@ -392,8 +389,8 @@ public function testUpdateImage(int $imageId, string $imageMD5): int $this->assertMatchesRegularExpression('@/img/p[/0-9]+/' . $imageId . '-small_default\.jpg@', $decodedResponse['thumbnailUrl']); $this->assertArrayHasKey('legends', $decodedResponse); $this->assertEquals([ - self::EN_LANG_ID => 'legend en', - self::$frenchLangId => 'legend fr', + 'en-US' => 'legend en', + 'fr-FR' => 'legend fr', ], $decodedResponse['legends']); $this->assertArrayHasKey('cover', $decodedResponse); $this->assertIsBool($decodedResponse['cover']); @@ -443,8 +440,8 @@ public function testListImages(int $productId, int $imageId): void 'imageUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($imageId, false), 'thumbnailUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($imageId, true), 'legends' => [ - self::EN_LANG_ID => 'legend en', - self::$frenchLangId => 'legend fr', + 'en-US' => 'legend en', + 'fr-FR' => 'legend fr', ], 'cover' => true, 'position' => 1, @@ -457,8 +454,8 @@ public function testListImages(int $productId, int $imageId): void 'imageUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($newImageId, false), 'thumbnailUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($newImageId, true), 'legends' => [ - self::EN_LANG_ID => '', - self::$frenchLangId => '', + 'en-US' => '', + 'fr-FR' => '', ], 'cover' => false, 'position' => 2, @@ -496,8 +493,8 @@ public function testListImages(int $productId, int $imageId): void 'imageUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($newImageId, false), 'thumbnailUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($newImageId, true), 'legends' => [ - self::EN_LANG_ID => '', - self::$frenchLangId => '', + 'en-US' => '', + 'fr-FR' => '', ], 'cover' => true, 'position' => 1, @@ -510,8 +507,8 @@ public function testListImages(int $productId, int $imageId): void 'imageUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($imageId, false), 'thumbnailUrl' => 'http://myshop.com/img/p/' . $this->getImagePath($imageId, true), 'legends' => [ - self::EN_LANG_ID => 'legend en', - self::$frenchLangId => 'legend fr', + 'en-US' => 'legend en', + 'fr-FR' => 'legend fr', ], 'cover' => false, 'position' => 2, diff --git a/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php b/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php index c103bcb..bc95ac7 100644 --- a/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php +++ b/tests/Integration/ApiPlatform/ProductMultiShopEndpointTest.php @@ -36,9 +36,6 @@ class ProductMultiShopEndpointTest extends ApiTestCase { - protected const EN_LANG_ID = 1; - protected static int $frenchLangId; - protected const DEFAULT_SHOP_GROUP_ID = 1; protected static int $secondShopGroupId; @@ -58,7 +55,7 @@ public static function setUpBeforeClass(): void ShopResetter::resetShops(); ConfigurationResetter::resetConfiguration(); - self::$frenchLangId = self::addLanguageByLocale('fr-FR'); + self::addLanguageByLocale('fr-FR'); self::updateConfiguration(MultistoreConfig::FEATURE_STATUS, 1); // Disable secure protection for the tests (the configuration reset forced the default config back) @@ -72,12 +69,12 @@ public static function setUpBeforeClass(): void self::$defaultProductData = [ 'type' => ProductType::TYPE_STANDARD, 'names' => [ - self::EN_LANG_ID => 'product name', - self::$frenchLangId => 'nom produit', + 'en-US' => 'product name', + 'fr-FR' => 'nom produit', ], 'descriptions' => [ - self::EN_LANG_ID => '', - self::$frenchLangId => '', + 'en-US' => '', + 'fr-FR' => '', ], 'active' => false, ]; @@ -114,8 +111,8 @@ public function testShopContextIsRequired(): void 'json' => [ 'type' => ProductType::TYPE_STANDARD, 'names' => [ - self::EN_LANG_ID => 'product name', - self::$frenchLangId => 'nom produit', + 'en-US' => 'product name', + 'fr-FR' => 'nom produit', ], ], ]); @@ -132,8 +129,8 @@ public function testCreateProductForFirstShop(): int 'json' => [ 'type' => ProductType::TYPE_STANDARD, 'names' => [ - self::EN_LANG_ID => 'product name', - self::$frenchLangId => 'nom produit', + 'en-US' => 'product name', + 'fr-FR' => 'nom produit', ], ], 'extra' => [