From 743d800f26876c0fccdb473495aed317d3ebebe1 Mon Sep 17 00:00:00 2001 From: Christian Dangl Date: Tue, 26 Sep 2023 10:44:19 +0200 Subject: [PATCH] NTR: add cheap fixture product for live tests --- .../config/services/fixtures/fixtures.xml | 6 ++ tests/Fixtures/Category/CategoryFixture.php | 1 + tests/Fixtures/Product/CheapProducts.php | 72 +++++++++++++++++++ tests/Fixtures/Product/FailureProducts.php | 22 +++--- tests/Fixtures/Product/RoundingProducts.php | 6 +- .../Fixtures/Product/SubscriptionFixture.php | 4 +- .../Product/Traits/ProductFixtureTrait.php | 5 +- tests/Fixtures/Product/VoucherFixture.php | 6 +- 8 files changed, 102 insertions(+), 20 deletions(-) create mode 100644 tests/Fixtures/Product/CheapProducts.php diff --git a/src/Resources/config/services/fixtures/fixtures.xml b/src/Resources/config/services/fixtures/fixtures.xml index 1fe8bd7f9..74eafaac1 100644 --- a/src/Resources/config/services/fixtures/fixtures.xml +++ b/src/Resources/config/services/fixtures/fixtures.xml @@ -48,5 +48,11 @@ + + + + + + diff --git a/tests/Fixtures/Category/CategoryFixture.php b/tests/Fixtures/Category/CategoryFixture.php index c4df7980b..bf4f31f7e 100644 --- a/tests/Fixtures/Category/CategoryFixture.php +++ b/tests/Fixtures/Category/CategoryFixture.php @@ -65,6 +65,7 @@ public function load(FixtureBag $bag): void $this->createCategory('0d9eefdd6d12456335280e2ff42431b2', "Subscriptions", $afterCatId); $this->createCategory('0d9eefdd6d12456335280e2ff42431b9', "Failures", $afterCatId); $this->createCategory('2a2eefdd6d12456335280e2ff42431b9', "Rounding", $afterCatId); + $this->createCategory('2a2eefdd6d12456335280e2ff42432b3', "Cheap", $afterCatId); } /** diff --git a/tests/Fixtures/Product/CheapProducts.php b/tests/Fixtures/Product/CheapProducts.php new file mode 100644 index 000000000..9f0914219 --- /dev/null +++ b/tests/Fixtures/Product/CheapProducts.php @@ -0,0 +1,72 @@ +helper = $helper; + $this->repoProducts = $repoProducts; + } + + /** + * @return string[] + */ + public function groups(): array + { + return [ + 'mollie', + 'mollie-demodata', + ]; + } + + /** + * @return string[] + */ + public function dependsOn(): array + { + return [ + CategoryFixture::class + ]; + } + + + /** + * @param FixtureBag $bag + * @return void + */ + public function load(FixtureBag $bag): void + { + $category = 'Cheap'; + $image = 'tshirt-black.png'; + $description = 'Mollie Product for testing purpose in development environment. You can use this cheap products for LIVE tests or other scenarios'; + + $this->createProduct('1d3eefdd2d22436385580e2fb43431b9', 'Cheap Mollie Shirt', 'MOL_CHEAP_1', $category, $description, 1, $image, true, [], $this->repoProducts, $this->helper); + } +} diff --git a/tests/Fixtures/Product/FailureProducts.php b/tests/Fixtures/Product/FailureProducts.php index ce1a1cf2b..92cb044f6 100644 --- a/tests/Fixtures/Product/FailureProducts.php +++ b/tests/Fixtures/Product/FailureProducts.php @@ -68,16 +68,16 @@ public function load(FixtureBag $bag): void $description = 'Mollie Product for testing purpose in development environment. Use "failed" on the Mollie Payment Sandbox page to force the special error reason of this product.'; - $this->createProduct('0d1eeedd6d22436385580e2ff42431b9', 'Invalid Card Number', 'MOL_ERROR_1', $category, $description, 1001, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d2eeedd6d22436385580e2ff42431b9', 'Invalid CVV', 'MOL_ERROR_2', $category, $description, 1002, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d3eeedd6d22436385580e2ff42431b9', 'Invalid Card Holder Name', 'MOL_ERROR_3', $category, $description, 1003, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d4eeedd6d22436385580e2ff42431b9', 'Card Expired', 'MOL_ERROR_4', $category, $description, 1004, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d5eeedd6d22436385580e2ff42431b9', 'Invalid Card Type', 'MOL_ERROR_5', $category, $description, 1005, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d6eeedd6d22436385580e2ff42431b9', 'Refused by Issuer', 'MOL_ERROR_6', $category, $description, 1006, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d7eeedd6d22436385580e2ff42431b9', 'Insufficient Funds', 'MOL_ERROR_7', $category, $description, 1007, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d8eeedd6d22436385580e2ff42431b9', 'Inactive Card', 'MOL_ERROR_8', $category, $description, 1008, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d9eeedd6d22436385580e2ff42431b9', 'Possible Fraud', 'MOL_ERROR_9', $category, $description, 1009, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d3eeedd6d10436385580e2ff42431b9', 'Authentication Failed', 'MOL_ERROR_10', $category, $description, 1010, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('0d3eeedd6d11436385580e2ff42431b9', 'Card Declined', 'MOL_ERROR_11', $category, $description, 1011, $image, [], $this->repoProducts, $this->helper); + $this->createProduct('0d1eeedd6d22436385580e2ff42431b9', 'Invalid Card Number', 'MOL_ERROR_1', $category, $description, 1001, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d2eeedd6d22436385580e2ff42431b9', 'Invalid CVV', 'MOL_ERROR_2', $category, $description, 1002, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d3eeedd6d22436385580e2ff42431b9', 'Invalid Card Holder Name', 'MOL_ERROR_3', $category, $description, 1003, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d4eeedd6d22436385580e2ff42431b9', 'Card Expired', 'MOL_ERROR_4', $category, $description, 1004, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d5eeedd6d22436385580e2ff42431b9', 'Invalid Card Type', 'MOL_ERROR_5', $category, $description, 1005, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d6eeedd6d22436385580e2ff42431b9', 'Refused by Issuer', 'MOL_ERROR_6', $category, $description, 1006, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d7eeedd6d22436385580e2ff42431b9', 'Insufficient Funds', 'MOL_ERROR_7', $category, $description, 1007, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d8eeedd6d22436385580e2ff42431b9', 'Inactive Card', 'MOL_ERROR_8', $category, $description, 1008, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d9eeedd6d22436385580e2ff42431b9', 'Possible Fraud', 'MOL_ERROR_9', $category, $description, 1009, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d3eeedd6d10436385580e2ff42431b9', 'Authentication Failed', 'MOL_ERROR_10', $category, $description, 1010, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('0d3eeedd6d11436385580e2ff42431b9', 'Card Declined', 'MOL_ERROR_11', $category, $description, 1011, $image, false, [], $this->repoProducts, $this->helper); } } diff --git a/tests/Fixtures/Product/RoundingProducts.php b/tests/Fixtures/Product/RoundingProducts.php index c7302b508..6b4bcf45c 100644 --- a/tests/Fixtures/Product/RoundingProducts.php +++ b/tests/Fixtures/Product/RoundingProducts.php @@ -55,8 +55,8 @@ public function load(FixtureBag $bag): void $image = 'tshirt-white.png'; $description = 'Product to test rounding issues.'; - $this->createProduct('7d1abedd2d22436385580e2ff42431b9', 'Product A 4 Decimals', 'MOL_ROUNDING_1', $category, $description, 2.7336, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('6d1abedd2d22436485580f3ff42431b9', 'Product B 4 Decimals', 'MOL_ROUNDING_2', $category, $description, 2.9334, $image, [], $this->repoProducts, $this->helper); - $this->createProduct('1a2abeed2d22436485580f3ff42431b9', 'Product C 4 Decimals', 'MOL_ROUNDING_3', $category, $description, 1.6494, $image, [], $this->repoProducts, $this->helper); + $this->createProduct('7d1abedd2d22436385580e2ff42431b9', 'Product A 4 Decimals', 'MOL_ROUNDING_1', $category, $description, 2.7336, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('6d1abedd2d22436485580f3ff42431b9', 'Product B 4 Decimals', 'MOL_ROUNDING_2', $category, $description, 2.9334, $image, false, [], $this->repoProducts, $this->helper); + $this->createProduct('1a2abeed2d22436485580f3ff42431b9', 'Product C 4 Decimals', 'MOL_ROUNDING_3', $category, $description, 1.6494, $image, false, [], $this->repoProducts, $this->helper); } } diff --git a/tests/Fixtures/Product/SubscriptionFixture.php b/tests/Fixtures/Product/SubscriptionFixture.php index 314488368..7bfedf095 100644 --- a/tests/Fixtures/Product/SubscriptionFixture.php +++ b/tests/Fixtures/Product/SubscriptionFixture.php @@ -67,7 +67,7 @@ public function load(FixtureBag $bag): void 'mollie_payments_product_subscription_interval_unit' => "week" ]; - $this->createProduct('1d1eeedd6d22436385580e2ff42431b9', 'Subscription (1x Daily)', 'MOL_SUB_1', $category, $description, 19, $image, $customFieldsDaily, $this->repoProducts, $this->helper); - $this->createProduct('1d2eeedd6d22436385580e2ff42431b9', 'Subscription (1x Weekly)', 'MOL_SUB_2', $category, $description, 29, $image, $customFieldsWeekly, $this->repoProducts, $this->helper); + $this->createProduct('1d1eeedd6d22436385580e2ff42431b9', 'Subscription (1x Daily)', 'MOL_SUB_1', $category, $description, 19, $image, false, $customFieldsDaily, $this->repoProducts, $this->helper); + $this->createProduct('1d2eeedd6d22436385580e2ff42431b9', 'Subscription (1x Weekly)', 'MOL_SUB_2', $category, $description, 29, $image, false, $customFieldsWeekly, $this->repoProducts, $this->helper); } } diff --git a/tests/Fixtures/Product/Traits/ProductFixtureTrait.php b/tests/Fixtures/Product/Traits/ProductFixtureTrait.php index 79b7eb1cc..4df81b007 100644 --- a/tests/Fixtures/Product/Traits/ProductFixtureTrait.php +++ b/tests/Fixtures/Product/Traits/ProductFixtureTrait.php @@ -17,11 +17,13 @@ trait ProductFixtureTrait * @param string $description * @param float $price * @param string $image + * @param bool $shippingFree * @param array $customFields * @param EntityRepository $repoProducts * @param FixtureHelper $helper + * @return void */ - protected function createProduct(string $id, string $name, string $number, string $categoryName, string $description, float $price, string $image, array $customFields, EntityRepository $repoProducts, FixtureHelper $helper): void + protected function createProduct(string $id, string $name, string $number, string $categoryName, string $description, float $price, string $image, bool $shippingFree, array $customFields, EntityRepository $repoProducts, FixtureHelper $helper): void { # just reuse the product one ;) $mediaId = $id; @@ -83,6 +85,7 @@ protected function createProduct(string $id, string $name, string $number, strin ], 'coverId' => $coverId, 'customFields' => $customFields, + 'shippingFree' => $shippingFree, ] ], Context::createDefaultContext() diff --git a/tests/Fixtures/Product/VoucherFixture.php b/tests/Fixtures/Product/VoucherFixture.php index 5e24ff2ea..62d1c51fe 100644 --- a/tests/Fixtures/Product/VoucherFixture.php +++ b/tests/Fixtures/Product/VoucherFixture.php @@ -67,8 +67,8 @@ public function load(FixtureBag $bag): void 'mollie_payments_product_voucher_type' => '3', ]; - $this->createProduct('4d1eeedd6d22436385580e2ff42431b9', 'Voucher ECO', 'MOL_VOUCHER_1', $category, $description, 19, $image, $customFieldsEco, $this->repoProducts, $this->helper); - $this->createProduct('5d1eeedd6d22436385580e2ff42431b9', 'Voucher MEAL', 'MOL_VOUCHER_2', $category, $description, 19, 'champagne.png', $customFieldsMeal, $this->repoProducts, $this->helper); - $this->createProduct('6d1eeedd6d22436385580e2ff42431b9', 'Voucher GIFT', 'MOL_VOUCHER_3', $category, $description, 19, $image, $customFieldsGift, $this->repoProducts, $this->helper); + $this->createProduct('4d1eeedd6d22436385580e2ff42431b9', 'Voucher ECO', 'MOL_VOUCHER_1', $category, $description, 19, $image, false, $customFieldsEco, $this->repoProducts, $this->helper); + $this->createProduct('5d1eeedd6d22436385580e2ff42431b9', 'Voucher MEAL', 'MOL_VOUCHER_2', $category, $description, 19, 'champagne.png', false, $customFieldsMeal, $this->repoProducts, $this->helper); + $this->createProduct('6d1eeedd6d22436385580e2ff42431b9', 'Voucher GIFT', 'MOL_VOUCHER_3', $category, $description, 19, $image, false, $customFieldsGift, $this->repoProducts, $this->helper); } }