Skip to content

Commit

Permalink
NTR: add cheap fixture product for live tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Sep 26, 2023
1 parent 098b573 commit 743d800
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 20 deletions.
6 changes: 6 additions & 0 deletions src/Resources/config/services/fixtures/fixtures.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,11 @@
<tag name="basecom.fixture"/>
</service>

<service id="MolliePayments\Fixtures\Product\CheapProducts">
<argument type="service" id="Basecom\FixturePlugin\FixtureHelper"/>
<argument type="service" id="product.repository"/>
<tag name="basecom.fixture"/>
</service>

</services>
</container>
1 change: 1 addition & 0 deletions tests/Fixtures/Category/CategoryFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
72 changes: 72 additions & 0 deletions tests/Fixtures/Product/CheapProducts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace MolliePayments\Fixtures\Product;

use Basecom\FixturePlugin\Fixture;
use Basecom\FixturePlugin\FixtureBag;
use Basecom\FixturePlugin\FixtureHelper;
use MolliePayments\Fixtures\Category\CategoryFixture;
use MolliePayments\Fixtures\Product\Traits\ProductFixtureTrait;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;

class CheapProducts extends Fixture
{
use ProductFixtureTrait;

/**
* @var FixtureHelper
*/
private $helper;

/**
* @var EntityRepository
*/
private $repoProducts;


/**
* @param FixtureHelper $helper
* @param EntityRepository $repoProducts
*/
public function __construct(FixtureHelper $helper, EntityRepository $repoProducts)
{
$this->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);
}
}
22 changes: 11 additions & 11 deletions tests/Fixtures/Product/FailureProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 3 additions & 3 deletions tests/Fixtures/Product/RoundingProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions tests/Fixtures/Product/SubscriptionFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
5 changes: 4 additions & 1 deletion tests/Fixtures/Product/Traits/ProductFixtureTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,6 +85,7 @@ protected function createProduct(string $id, string $name, string $number, strin
],
'coverId' => $coverId,
'customFields' => $customFields,
'shippingFree' => $shippingFree,
]
],
Context::createDefaultContext()
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixtures/Product/VoucherFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 743d800

Please sign in to comment.