Skip to content

Commit

Permalink
NTR: update qa (mollie#779)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitalij Mik <[email protected]>
  • Loading branch information
BlackScorp and Vitalij Mik authored Jul 1, 2024
1 parent 82bb328 commit 5d33ffe
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 53 deletions.
42 changes: 23 additions & 19 deletions tests/Fixtures/Category/CategoryFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
use Basecom\FixturePlugin\FixtureBag;
use Basecom\FixturePlugin\FixtureHelper;
use Shopware\Core\Content\Category\CategoryEntity;
use Shopware\Core\Framework\Api\Context\SystemSource;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Uuid\Uuid;

class CategoryFixture extends Fixture
{
/**
* @var FixtureHelper
*/
private $helper;

/**
* @var EntityRepository
Expand Down Expand Up @@ -53,29 +53,33 @@ public function groups(): array
*/
public function load(): void
{
$appendCategory = $this->helper->Category()->getByName('Free time & electronics');
$context = new Context(new SystemSource());
$criteria = new Criteria();
$criteria->addFilter(new EqualsFilter('name', 'Free time & electronics'));
$categorySearchResult = $this->categoryRepository->search($criteria, $context);

/** @var CategoryEntity $category */
$category = $categorySearchResult->first();

if (!$appendCategory instanceof CategoryEntity) {
$appendCategory = $this->helper->Category()->getFirst();
}
$afterCatId = $category->getId();
$parentId = $category->getParentId();
$cmsPageId = $category->getCmsPageId();

$afterCatId = ($appendCategory instanceof CategoryEntity) ? $appendCategory->getId() : null;

$this->createCategory('0d8eefdd6d12456335280e2ff42431b9', "Voucher", $afterCatId);
$this->createCategory('0d9eefdd6d12456335280e2ff42431b2', "Subscriptions", $afterCatId);
$this->createCategory('0d9eefdd6d12456335280e2ff42431b9', "Failures", $afterCatId);
$this->createCategory('2a2eefdd6d12456335280e2ff42431b9', "Rounding", $afterCatId);
$this->createCategory('2a2eefdd6d12456335280e2ff42432b3', "Cheap", $afterCatId);
$this->createCategory(Uuid::fromStringToHex('Voucher'), "Voucher", $context, $afterCatId, $parentId, $cmsPageId);
$this->createCategory(Uuid::fromStringToHex('Subscriptions'), "Subscriptions", $context, $afterCatId, $parentId, $cmsPageId);
$this->createCategory(Uuid::fromStringToHex('Failures'), "Failures", $context, $afterCatId, $parentId, $cmsPageId);
$this->createCategory(Uuid::fromStringToHex('Rounding'), "Rounding", $context, $afterCatId, $parentId, $cmsPageId);
$this->createCategory(Uuid::fromStringToHex('Cheap'), "Cheap", $context, $afterCatId, $parentId, $cmsPageId);
}

/**
* @param string $id
* @param string $name
* @param null|string $afterCategoryId
*/
private function createCategory(string $id, string $name, ?string $afterCategoryId): void
private function createCategory(string $id, string $name, Context $context, ?string $afterCategoryId, ?string $parentId, ?string $cmsPageId): void
{
$parentRoot = $this->helper->Category()->getRootCategory();

$this->categoryRepository->upsert([
[
Expand All @@ -94,10 +98,10 @@ private function createCategory(string $id, string $name, ?string $afterCategory
'displayNestedProducts' => true,
'visible' => true,
'type' => 'page',
'cmsPageId' => $this->helper->Cms()->getDefaultCategoryLayout()->getId(),
'parentId' => $parentRoot->getId(),
'cmsPageId' => $cmsPageId,
'parentId' => $parentId,
'afterCategoryId' => $afterCategoryId,
],
], Context::createDefaultContext());
], $context);
}
}
16 changes: 6 additions & 10 deletions tests/Fixtures/Customer/CustomerFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Basecom\FixturePlugin\Fixture;
use Basecom\FixturePlugin\FixtureBag;
use Basecom\FixturePlugin\FixtureHelper;
use Kiener\MolliePayments\Repository\Customer\CustomerRepositoryInterface;
use Basecom\FixturePlugin\Utils\SalutationUtils;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;

class CustomerFixture extends Fixture
{
Expand All @@ -19,10 +19,6 @@ class CustomerFixture extends Fixture
private const ADDRESS_ID_DE = 'e27ddeb4e85f4a0f9a912a09f07701b0';


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

/**
* @var EntityRepository
Expand All @@ -34,7 +30,7 @@ class CustomerFixture extends Fixture
* @param FixtureHelper $helper
* @param EntityRepository $customerRepository
*/
public function __construct(FixtureHelper $helper, $customerRepository)
public function __construct(FixtureHelper $helper,EntityRepository $customerRepository)
{
$this->helper = $helper;
$this->customerRepository = $customerRepository;
Expand Down Expand Up @@ -66,16 +62,16 @@ public function load(): void
'defaultPaymentMethodId' => $this->helper->PaymentMethod()->getInvoicePaymentMethod()->getId(),
'defaultBillingAddress' => [
'id' => self::ADDRESS_ID_NL,
'salutationId' => $this->helper->Customer()->getNotSpecifiedSalutation()->getId(),
'salutationId' => $this->helper->Salutation()->getNotSpecifiedSalutation()->getId(),
'firstName' => 'Mollie NL',
'lastName' => 'Test',
'zipcode' => '1015 CW',
'street' => 'Keizersgracht 126',
'city' => 'Amsterdam',
'countryId' => $this->helper->SalesChannel()->getCountry('NL')->getId(),
'countryId' => $this->helper->LanguageAndLocale()->getCountry('NL')->getId(),
],
'defaultShippingAddressId' => self::ADDRESS_ID_NL,
'salutationId' => $this->helper->Customer()->getNotSpecifiedSalutation()->getId(),
'salutationId' => $this->helper->Salutation()->getNotSpecifiedSalutation()->getId(),
'customerNumber' => '1122',
'firstName' => 'Mollie NL',
'lastName' => 'Test',
Expand Down
5 changes: 0 additions & 5 deletions tests/Fixtures/Product/CheapProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class CheapProducts extends Fixture
{
use ProductFixtureTrait;

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

/**
* @var EntityRepository
*/
Expand Down
4 changes: 0 additions & 4 deletions tests/Fixtures/Product/FailureProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ class FailureProducts extends Fixture
{
use ProductFixtureTrait;

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

/**
* @var EntityRepository
Expand Down
4 changes: 0 additions & 4 deletions tests/Fixtures/Product/RoundingProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class RoundingProducts extends Fixture
{
use ProductFixtureTrait;

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

/**
* @var EntityRepository
Expand Down
4 changes: 0 additions & 4 deletions tests/Fixtures/Product/SubscriptionFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class SubscriptionFixture extends Fixture
{
use ProductFixtureTrait;

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

/**
* @var EntityRepository
Expand Down
8 changes: 5 additions & 3 deletions tests/Fixtures/Product/Traits/ProductFixtureTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
namespace MolliePayments\Fixtures\Product\Traits;

use Basecom\FixturePlugin\FixtureHelper;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\Uuid\Uuid;

trait ProductFixtureTrait
{
Expand Down Expand Up @@ -53,7 +55,7 @@ protected function createProduct(string $id, string $name, string $number, strin
[
'id' => $id,
'name' => $name,
'taxId' => $helper->SalesChannel()->getTax19()->getId(),
'taxId' => $helper->Tax()->getTax19()->getId(),
'productNumber' => $number,
'description' => $description,
'visibilities' => [
Expand All @@ -65,13 +67,13 @@ protected function createProduct(string $id, string $name, string $number, strin
],
'categories' => [
[
'id' => $helper->Category()->getByName($categoryName)->getId(),
'id' => Uuid::fromStringToHex($categoryName),
]
],
'stock' => 10,
'price' => [
[
'currencyId' => $helper->SalesChannel()->getCurrencyEuro()->getId(),
'currencyId' => Defaults::CURRENCY,
'gross' => $price,
'net' => $price,
'linked' => true,
Expand Down
4 changes: 0 additions & 4 deletions tests/Fixtures/Product/VoucherFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class VoucherFixture extends Fixture
{
use ProductFixtureTrait;

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

/**
* @var EntityRepository
Expand Down

0 comments on commit 5d33ffe

Please sign in to comment.