-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
312 additions
and
132 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
use App\Model\Administrator\Administrator; | ||
use App\Model\Order\Order; | ||
use App\Model\Order\PromoCode\PromoCode; | ||
use App\Model\Order\Status\OrderStatus; | ||
use App\Model\Payment\Payment; | ||
use App\Model\Product\Product; | ||
|
@@ -24,6 +25,8 @@ | |
use Shopsys\FrameworkBundle\Model\Order\PlaceOrderFacade; | ||
use Shopsys\FrameworkBundle\Model\Order\Processing\OrderInputFactory; | ||
use Shopsys\FrameworkBundle\Model\Order\Processing\OrderProcessor; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyDataFactory; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade; | ||
|
||
class OrderDataFixture extends AbstractReferenceFixture implements DependentFixtureInterface | ||
|
@@ -42,6 +45,7 @@ class OrderDataFixture extends AbstractReferenceFixture implements DependentFixt | |
* @param \Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade $currencyFacade | ||
* @param \Shopsys\FrameworkBundle\Model\Order\Processing\OrderProcessor $orderProcessor | ||
* @param \Shopsys\FrameworkBundle\Model\Order\Processing\OrderInputFactory $orderInputFactory | ||
* @param \Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyDataFactory $currencyDataFactory | ||
*/ | ||
public function __construct( | ||
private readonly CustomerUserRepository $customerUserRepository, | ||
|
@@ -51,6 +55,7 @@ public function __construct( | |
private readonly CurrencyFacade $currencyFacade, | ||
private readonly OrderProcessor $orderProcessor, | ||
private readonly OrderInputFactory $orderInputFactory, | ||
private readonly CurrencyDataFactory $currencyDataFactory, | ||
) { | ||
} | ||
|
||
|
@@ -775,6 +780,8 @@ private function loadDistinct(int $domainId): void | |
PaymentDataFixture::PAYMENT_LATER, | ||
$customerUser, | ||
); | ||
|
||
$this->createOrderWithPromoCodeAndRounding($domainDefaultCurrency, $domainId); | ||
} | ||
|
||
/** | ||
|
@@ -783,6 +790,7 @@ private function loadDistinct(int $domainId): void | |
* @param string $transportReferenceName | ||
* @param string $paymentReferenceName | ||
* @param \App\Model\Customer\User\CustomerUser|null $customerUser | ||
* @param \App\Model\Order\PromoCode\PromoCode|null $promoCode | ||
* @return \App\Model\Order\Order | ||
*/ | ||
private function createOrder( | ||
|
@@ -791,6 +799,7 @@ private function createOrder( | |
string $transportReferenceName, | ||
string $paymentReferenceName, | ||
?CustomerUser $customerUser = null, | ||
?PromoCode $promoCode = null, | ||
): Order { | ||
$uniqueOrderHash = $orderData->domainId . '-'; | ||
|
||
|
@@ -802,6 +811,10 @@ private function createOrder( | |
$orderInput->setPayment($payment); | ||
$orderInput->setCustomerUser($customerUser); | ||
|
||
if ($promoCode !== null) { | ||
$orderInput->addPromoCode($promoCode); | ||
} | ||
|
||
foreach ($products as $productReferenceName => $quantity) { | ||
$product = $this->getReference($productReferenceName, Product::class); | ||
$orderInput->addProduct($product, $quantity); | ||
|
@@ -837,6 +850,48 @@ public function getDependencies(): array | |
OrderStatusDataFixture::class, | ||
CountryDataFixture::class, | ||
SettingValueDataFixture::class, | ||
PromoCodeDataFixture::class, | ||
]; | ||
} | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency $domainDefaultCurrency | ||
* @param int $domainId | ||
*/ | ||
private function createOrderWithPromoCodeAndRounding(Currency $domainDefaultCurrency, int $domainId): void | ||
{ | ||
$currencyData = $this->currencyDataFactory->createFromCurrency($domainDefaultCurrency); | ||
$originalRounding = $currencyData->roundingType; | ||
$currencyData->roundingType = Currency::ROUNDING_TYPE_HUNDREDTHS; | ||
$this->currencyFacade->edit($domainDefaultCurrency->getId(), $currencyData); | ||
|
||
$orderData = $this->orderDataFactory->create(); | ||
$orderData->status = $this->getReference(OrderStatusDataFixture::ORDER_STATUS_NEW, OrderStatus::class); | ||
$orderData->firstName = 'Peťka'; | ||
$orderData->lastName = 'Šuster'; | ||
$orderData->email = '[email protected]'; | ||
$orderData->telephone = '+420123456789'; | ||
$orderData->street = 'Petřkovická 123'; | ||
$orderData->city = 'Ostrava Lhotka'; | ||
$orderData->postcode = '71200'; | ||
$orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC, Country::class); | ||
$orderData->deliveryAddressSameAsBillingAddress = true; | ||
$orderData->domainId = $domainId; | ||
$orderData->currency = $domainDefaultCurrency; | ||
$orderData->createdAt = new DateTime('now'); | ||
$this->createOrder( | ||
$orderData, | ||
[ | ||
ProductDataFixture::PRODUCT_PREFIX . '1' => 1, | ||
ProductDataFixture::PRODUCT_PREFIX . '2' => 1, | ||
], | ||
TransportDataFixture::TRANSPORT_CZECH_POST, | ||
PaymentDataFixture::PAYMENT_CASH, | ||
null, | ||
$this->getReferenceForDomain(PromoCodeDataFixture::VALID_PROMO_CODE, $domainId, PromoCode::class), | ||
); | ||
|
||
$currencyData->roundingType = $originalRounding; | ||
$this->currencyFacade->edit($domainDefaultCurrency->getId(), $currencyData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,12 @@ | |
|
||
class OrderMailTest extends TransactionFunctionalTestCase | ||
{ | ||
public function testGetMailTemplateNameByStatus() | ||
/** | ||
* @inject | ||
*/ | ||
private OrderItemPriceCalculation $orderItemPriceCalculation; | ||
|
||
public function testGetMailTemplateNameByStatus(): void | ||
{ | ||
$orderStatus1 = $this->getMockBuilder(OrderStatus::class) | ||
->onlyMethods(['getId']) | ||
|
@@ -50,7 +55,7 @@ public function testGetMailTemplateNameByStatus() | |
$this->assertNotSame($mailTempleteName1, $mailTempleteName2); | ||
} | ||
|
||
public function testGetMessageByOrder() | ||
public function testGetMessageByOrder(): void | ||
{ | ||
$routerMock = $this->getMockBuilder(RouterInterface::class)->getMock(); | ||
$routerMock->expects($this->any())->method('generate')->willReturn('generatedUrl'); | ||
|
@@ -62,9 +67,6 @@ public function testGetMessageByOrder() | |
$domainRouterFactoryMock->expects($this->any())->method('getRouter')->willReturn($routerMock); | ||
|
||
$twigMock = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock(); | ||
$orderItemPriceCalculationMock = $this->getMockBuilder( | ||
OrderItemPriceCalculation::class, | ||
)->disableOriginalConstructor()->getMock(); | ||
$settingMock = $this->getMockBuilder(Setting::class)->disableOriginalConstructor()->getMock(); | ||
$settingMock->expects($this->any())->method('getForDomain')->willReturn('[email protected]'); | ||
$priceExtensionMock = $this->getMockBuilder(PriceExtension::class)->disableOriginalConstructor()->getMock(); | ||
|
@@ -82,7 +84,7 @@ public function testGetMessageByOrder() | |
$settingMock, | ||
$domainRouterFactoryMock, | ||
$twigMock, | ||
$orderItemPriceCalculationMock, | ||
$this->orderItemPriceCalculation, | ||
$this->domain, | ||
$priceExtensionMock, | ||
$dateTimeFormatterExtensionMock, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.