-
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.
fixed creating order with no products (#2221)
- Loading branch information
Showing
1 changed file
with
109 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -161,4 +161,113 @@ private function getMutation(): string | |
} | ||
}'; | ||
} | ||
|
||
public function testCreateMinimalOrderWithNoProductsThrowError(): void | ||
{ | ||
$response = $this->getResponseContentForQuery($this->getMutationWithNoProducts()); | ||
$this->assertResponseContainsArrayOfExtensionValidationErrors($response); | ||
$errors = $this->getErrorsExtensionValidationFromResponse($response); | ||
|
||
static::assertArrayHasKey('input.products', $errors); | ||
static::assertCount(1, $errors['input.products']); | ||
static::assertArrayHasKey(0, $errors['input.products']); | ||
static::assertArrayHasKey('message', $errors['input.products'][0]); | ||
static::assertSame('Please enter at least one product', $errors['input.products'][0]['message']); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private function getMutationWithNoProducts(): string | ||
{ | ||
$domainId = $this->domain->getId(); | ||
/** @var \Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat $vatHigh */ | ||
$vatHigh = $this->getReferenceForDomain(VatDataFixture::VAT_HIGH, $domainId); | ||
/** @var \Shopsys\FrameworkBundle\Model\Pricing\Vat\Vat $vatZero */ | ||
$vatZero = $this->getReferenceForDomain(VatDataFixture::VAT_ZERO, $domainId); | ||
|
||
/** @var \Shopsys\FrameworkBundle\Model\Payment\Payment $paymentCashOnDelivery */ | ||
$paymentCashOnDelivery = $this->getReference(PaymentDataFixture::PAYMENT_CASH_ON_DELIVERY); | ||
$paymentPrice = $this->getMutationPriceConvertedToDomainDefaultCurrency('50', $vatZero); | ||
|
||
/** @var \Shopsys\FrameworkBundle\Model\Transport\Transport $transportCzechPost */ | ||
$transportCzechPost = $this->getReference(TransportDataFixture::TRANSPORT_CZECH_POST); | ||
$transportPrice = $this->getMutationPriceConvertedToDomainDefaultCurrency('100', $vatHigh); | ||
|
||
return 'mutation { | ||
CreateOrder( | ||
input: { | ||
firstName: "firstName" | ||
lastName: "lastName" | ||
email: "[email protected]" | ||
telephone: "+53 123456789" | ||
onCompanyBehalf: false | ||
street: "123 Fake Street" | ||
city: "Springfield" | ||
postcode: "12345" | ||
country: "CZ" | ||
payment: { | ||
uuid: "' . $paymentCashOnDelivery->getUuid() . '" | ||
price: ' . $paymentPrice . ' | ||
} | ||
transport: { | ||
uuid: "' . $transportCzechPost->getUuid() . '" | ||
price: ' . $transportPrice . ' | ||
} | ||
differentDeliveryAddress: false | ||
products: [] | ||
} | ||
) { | ||
transport { | ||
name | ||
} | ||
payment { | ||
name | ||
} | ||
status | ||
totalPrice { | ||
priceWithVat | ||
priceWithoutVat | ||
vatAmount | ||
} | ||
items { | ||
name | ||
unitPrice { | ||
priceWithVat | ||
priceWithoutVat | ||
vatAmount | ||
} | ||
totalPrice { | ||
priceWithVat | ||
priceWithoutVat | ||
vatAmount | ||
} | ||
quantity | ||
vatRate | ||
unit | ||
} | ||
firstName | ||
lastName | ||
telephone | ||
companyName | ||
companyNumber | ||
companyTaxNumber | ||
street | ||
city | ||
postcode | ||
country | ||
differentDeliveryAddress | ||
deliveryFirstName | ||
deliveryLastName | ||
deliveryCompanyName | ||
deliveryTelephone | ||
deliveryStreet | ||
deliveryCity | ||
deliveryPostcode | ||
deliveryCountry | ||
note | ||
} | ||
}'; | ||
} | ||
} |