Skip to content

Commit

Permalink
fixed creating order with no products (#2221)
Browse files Browse the repository at this point in the history
  • Loading branch information
s3tezsky authored Feb 2, 2021
1 parent df00350 commit b90cfee
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions tests/FrontendApiBundle/Functional/Order/MinimalOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
email
telephone
companyName
companyNumber
companyTaxNumber
street
city
postcode
country
differentDeliveryAddress
deliveryFirstName
deliveryLastName
deliveryCompanyName
deliveryTelephone
deliveryStreet
deliveryCity
deliveryPostcode
deliveryCountry
note
}
}';
}
}

0 comments on commit b90cfee

Please sign in to comment.