Skip to content

Commit

Permalink
fixup! data fixtures: multidomain orders are now created in OrderData…
Browse files Browse the repository at this point in the history
…Fixture
  • Loading branch information
vitek-rostislav committed Oct 4, 2019
1 parent 820bd2e commit aa30cd9
Showing 1 changed file with 39 additions and 32 deletions.
Expand Up @@ -92,18 +92,20 @@ public function load(ObjectManager $manager)
foreach ($this->domain->getAll() as $domainConfig) {
$domainId = $domainConfig->getId();
if ($domainId === 2) {
$this->loadForSecondDomain();
$this->loadDistinct($domainId);
} else {
$this->loadForAnyDomainExcludingSecond($domainId);
$this->loadDefault($domainId);
}
}
}

/**
* @param int $domainId
*/
protected function loadForAnyDomainExcludingSecond(int $domainId): void
protected function loadDefault(int $domainId): void
{
$domainDefaultCurrency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);

$user = $this->userRepository->findUserByEmailAndDomain('no-reply@shopsys.com', $domainId);
$orderData = $this->orderDataFactory->create();
$orderData->transport = $this->getReference(TransportDataFixture::TRANSPORT_PERSONAL);
Expand All @@ -119,7 +121,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -144,7 +146,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$orderData->createdAsAdministrator = $this->getReference(AdministratorDataFixture::ADMINISTRATOR);
$this->createOrder(
Expand Down Expand Up @@ -172,7 +174,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -197,7 +199,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -221,7 +223,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$orderData->createdAsAdministrator = $this->getReference(AdministratorDataFixture::SUPERADMINISTRATOR);
$this->createOrder(
Expand All @@ -248,7 +250,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand Down Expand Up @@ -277,7 +279,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -302,7 +304,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$orderData->createdAsAdministrator = $this->getReference(AdministratorDataFixture::SUPERADMINISTRATOR);
$this->createOrder(
Expand All @@ -328,7 +330,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -352,7 +354,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -375,7 +377,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -400,7 +402,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -424,7 +426,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$orderData->createdAsAdministrator = $this->getReference(AdministratorDataFixture::ADMINISTRATOR);
$this->createOrder(
Expand All @@ -449,7 +451,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -475,7 +477,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand Down Expand Up @@ -503,7 +505,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->companyNumber = '555555';
$orderData->note = 'Doufám, že vše dorazí v pořádku a co nejdříve :)';
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand Down Expand Up @@ -541,7 +543,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->companyNumber = '555555';
$orderData->note = 'Doufám, že vše dorazí v pořádku a co nejdříve :)';
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$orderData->createdAsAdministrator = $this->getReference(AdministratorDataFixture::ADMINISTRATOR);
$this->createOrder(
Expand Down Expand Up @@ -581,7 +583,7 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
$orderData->companyNumber = '555555';
$orderData->note = 'Doufám, že vše dorazí v pořádku a co nejdříve :)';
$orderData->domainId = $domainId;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-2 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -596,8 +598,13 @@ protected function loadForAnyDomainExcludingSecond(int $domainId): void
);
}

protected function loadForSecondDomain()
/**
* @param int $domainId
*/
protected function loadDistinct(int $domainId)
{
$domainDefaultCurrency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId($domainId);

$orderData = $this->orderDataFactory->create();
$orderData->transport = $this->getReference(TransportDataFixture::TRANSPORT_CZECH_POST);
$orderData->payment = $this->getReference(PaymentDataFixture::PAYMENT_CASH_ON_DELIVERY);
Expand All @@ -611,8 +618,8 @@ protected function loadForSecondDomain()
$orderData->postcode = '71200';
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = 2;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId(2);
$orderData->domainId = $domainId;
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-1 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -621,7 +628,7 @@ protected function loadForSecondDomain()
]
);

$user = $this->userRepository->findUserByEmailAndDomain('no-reply.2@shopsys.com', 2);
$user = $this->userRepository->findUserByEmailAndDomain('no-reply.2@shopsys.com', $domainId);
$orderData = $this->orderDataFactory->create();
$orderData->transport = $this->getReference(TransportDataFixture::TRANSPORT_PERSONAL);
$orderData->payment = $this->getReference(PaymentDataFixture::PAYMENT_CASH);
Expand All @@ -647,8 +654,8 @@ protected function loadForSecondDomain()
$orderData->deliveryPostcode = '54321';
$orderData->deliveryCountry = $this->getReference(CountryDataFixture::COUNTRY_SLOVAKIA);
$orderData->note = 'Prosím o dodání do pátku. Děkuji.';
$orderData->domainId = 2;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId(2);
$orderData->domainId = $domainId;
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-1 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -659,7 +666,7 @@ protected function loadForSecondDomain()
$user
);

$user = $this->userRepository->findUserByEmailAndDomain('no-reply.7@shopsys.com', 2);
$user = $this->userRepository->findUserByEmailAndDomain('no-reply.7@shopsys.com', $domainId);
$orderData = $this->orderDataFactory->create();
$orderData->transport = $this->getReference(TransportDataFixture::TRANSPORT_CZECH_POST);
$orderData->payment = $this->getReference(PaymentDataFixture::PAYMENT_CASH_ON_DELIVERY);
Expand All @@ -673,8 +680,8 @@ protected function loadForSecondDomain()
$orderData->postcode = '65421';
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = 2;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId(2);
$orderData->domainId = $domainId;
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-1 week', 'now');
$this->createOrder(
$orderData,
Expand All @@ -698,8 +705,8 @@ protected function loadForSecondDomain()
$orderData->postcode = '71201';
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = true;
$orderData->domainId = 2;
$orderData->currency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId(2);
$orderData->domainId = $domainId;
$orderData->currency = $domainDefaultCurrency;
$orderData->createdAt = $this->faker->dateTimeBetween('-1 week', 'now');
$this->createOrder(
$orderData,
Expand Down

0 comments on commit aa30cd9

Please sign in to comment.