'$cart.id$', 'product_id' => '$product.id$']), DataFixture(SetBillingAddressFixture::class, ['cart_id' => '$cart.id$']), DataFixture(SetShippingAddressFixture::class, ['cart_id' => '$cart.id$']), DataFixture(SetGuestEmailFixture::class, ['cart_id' => '$cart.id$'], 'email'), DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$cart.id$']), DataFixture(SetPaymentMethodFixture::class, ['cart_id' => '$cart.id$']), DataFixture(QuoteIdMask::class, ['cart_id' => '$cart.id$'], 'quoteIdMask'), ] public function testGuestOrder(): void { $maskedQuoteId = DataFixtureStorageManager::getStorage()->get('quoteIdMask')->getMaskedId(); $placeOrderQuery = strtr( self::PLACE_ORDER, [ '%cart_id' => $maskedQuoteId ] ); $placeOrderResponse = $this->graphQlMutation($placeOrderQuery); $this->assertNotEmpty($placeOrderResponse['placeOrder']['orderV2']['number']); $this->assertNotEmpty($placeOrderResponse['placeOrder']['orderV2']['token']); $this->assertNotEmpty($placeOrderResponse['placeOrder']['orderV2']['email']); $this->assertNotEmpty($placeOrderResponse['placeOrder']['orderV2']['billing_address']['firstname']); $this->assertNotEmpty($placeOrderResponse['placeOrder']['orderV2']['billing_address']['lastname']); $query = strtr( self::GUEST_ORDER_BY_TOKEN, [ '%token' => $placeOrderResponse['placeOrder']['orderV2']['token'], ] ); $response = $this->graphQlQuery($query); self::assertEquals( [ 'guestOrderByToken' => [ 'number' => $placeOrderResponse['placeOrder']['orderV2']['number'], 'email' => $placeOrderResponse['placeOrder']['orderV2']['email'], 'billing_address' => [ 'firstname' => $placeOrderResponse['placeOrder']['orderV2']['billing_address']['firstname'], 'lastname' => $placeOrderResponse['placeOrder']['orderV2']['billing_address']['lastname'] ] ] ], $response ); } #[ DataFixture(Customer::class, as: 'customer'), DataFixture(ProductFixture::class, as: 'product'), DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'cart'), DataFixture(AddProductToCartFixture::class, ['cart_id' => '$cart.id$', 'product_id' => '$product.id$']), DataFixture(SetBillingAddressFixture::class, ['cart_id' => '$cart.id$']), DataFixture(SetShippingAddressFixture::class, ['cart_id' => '$cart.id$']), DataFixture(SetGuestEmailFixture::class, ['cart_id' => '$cart.id$']), DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$cart.id$']), DataFixture(SetPaymentMethodFixture::class, ['cart_id' => '$cart.id$']), DataFixture(PlaceOrderFixture::class, ['cart_id' => '$cart.id$'], 'order'), ] public function testCustomerOrder(): void { $this->expectExceptionMessage('Please login to view the order.'); /** @var OrderInterface $order */ $order = DataFixtureStorageManager::getStorage()->get('order'); $query = strtr( self::GUEST_ORDER_BY_TOKEN, [ '%token' => Bootstrap::getObjectManager()->get(Token::class)->encrypt( $order->getIncrementId(), $order->getBillingAddress()->getEmail(), $order->getBillingAddress()->getPostcode() ) ] ); $this->graphQlQuery($query); } public function testGuestOrderIncorrectToken(): void { $this->expectExceptionMessage('We couldn\'t locate an order with the information provided.'); $query = strtr( self::GUEST_ORDER_BY_TOKEN, [ '%token' => 'incorrect' ] ); $this->graphQlQuery($query); } }