|
7 | 7 |
|
8 | 8 | namespace Magento\GraphQl\Sales;
|
9 | 9 |
|
| 10 | +use Magento\Catalog\Test\Fixture\Product as ProductFixture; |
| 11 | +use Magento\Checkout\Test\Fixture\PlaceOrder as PlaceOrderFixture; |
| 12 | +use Magento\Checkout\Test\Fixture\SetBillingAddress as SetBillingAddressFixture; |
| 13 | +use Magento\Checkout\Test\Fixture\SetDeliveryMethod as SetDeliveryMethodFixture; |
| 14 | +use Magento\Checkout\Test\Fixture\SetGuestEmail as SetGuestEmailFixture; |
| 15 | +use Magento\Checkout\Test\Fixture\SetPaymentMethod as SetPaymentMethodFixture; |
| 16 | +use Magento\Checkout\Test\Fixture\SetShippingAddress as SetShippingAddressFixture; |
| 17 | +use Magento\Customer\Test\Fixture\Customer; |
10 | 18 | use Magento\Framework\Registry;
|
| 19 | +use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture; |
| 20 | +use Magento\Quote\Test\Fixture\CustomerCart; |
| 21 | +use Magento\Quote\Test\Fixture\GuestCart as GuestCartFixture; |
11 | 22 | use Magento\Sales\Api\OrderRepositoryInterface;
|
12 | 23 | use Magento\Sales\Model\ResourceModel\Order\Collection;
|
| 24 | +use Magento\Sales\Test\Fixture\Invoice as InvoiceFixture; |
| 25 | +use Magento\Sales\Test\Fixture\InvoiceComment as InvoiceCommentFixture ; |
| 26 | +use Magento\TestFramework\Fixture\DataFixture; |
13 | 27 | use Magento\TestFramework\Helper\Bootstrap;
|
14 | 28 | use Magento\TestFramework\TestCase\GraphQlAbstract;
|
15 | 29 | use Magento\GraphQl\GetCustomerAuthenticationHeader;
|
@@ -410,6 +424,64 @@ public function testPartialInvoiceForCustomerWithTaxesAndDiscounts()
|
410 | 424 | $this->deleteOrder();
|
411 | 425 | }
|
412 | 426 |
|
| 427 | + #[ |
| 428 | + DataFixture(Customer::class, ['email' => 'customer@search.example.com'], as: 'customer'), |
| 429 | + DataFixture(ProductFixture::class, as: 'product'), |
| 430 | + DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'cart'), |
| 431 | + DataFixture(AddProductToCartFixture::class, ['cart_id' => '$cart.id$', 'product_id' => '$product.id$']), |
| 432 | + DataFixture(SetBillingAddressFixture::class, ['cart_id' => '$cart.id$']), |
| 433 | + DataFixture(SetShippingAddressFixture::class, ['cart_id' => '$cart.id$']), |
| 434 | + DataFixture(SetGuestEmailFixture::class, ['cart_id' => '$cart.id$']), |
| 435 | + DataFixture(SetDeliveryMethodFixture::class, ['cart_id' => '$cart.id$']), |
| 436 | + DataFixture(SetPaymentMethodFixture::class, ['cart_id' => '$cart.id$']), |
| 437 | + DataFixture(PlaceOrderFixture::class, ['cart_id' => '$cart.id$'], 'order'), |
| 438 | + DataFixture(InvoiceFixture::class, ['order_id' => '$order.id$'], 'invoice'), |
| 439 | + DataFixture(InvoiceCommentFixture::class, [ |
| 440 | + 'parent_id' => '$invoice.id$', |
| 441 | + 'comment' => 'visible_comment', |
| 442 | + 'is_visible_on_front' => 1, |
| 443 | + ]), |
| 444 | + DataFixture(InvoiceCommentFixture::class, [ |
| 445 | + 'parent_id' => '$invoice.id$', |
| 446 | + 'comment' => 'non_visible_comment', |
| 447 | + 'is_visible_on_front' => 0, |
| 448 | + ]), |
| 449 | + ] |
| 450 | + public function testInvoiceCommentsQuery() |
| 451 | + { |
| 452 | + $query = |
| 453 | + <<<QUERY |
| 454 | +{ |
| 455 | + customer { |
| 456 | + orders { |
| 457 | + items { |
| 458 | + invoices { |
| 459 | + comments { |
| 460 | + message |
| 461 | + timestamp |
| 462 | + } |
| 463 | + } |
| 464 | + } |
| 465 | + } |
| 466 | + } |
| 467 | +} |
| 468 | +QUERY; |
| 469 | + |
| 470 | + $currentEmail = 'customer@search.example.com'; |
| 471 | + $currentPassword = 'password'; |
| 472 | + $response = $this->graphQlQuery( |
| 473 | + $query, |
| 474 | + [], |
| 475 | + '', |
| 476 | + $this->customerAuthenticationHeader->execute($currentEmail, $currentPassword) |
| 477 | + ); |
| 478 | + |
| 479 | + $invoice = $response['customer']['orders']['items'][0]['invoices'][0]; |
| 480 | + $this->assertCount(1, $invoice['comments']); |
| 481 | + $this->assertEquals('visible_comment', $invoice['comments'][0]['message']); |
| 482 | + $this->assertNotEmpty($invoice['comments'][0]['timestamp']); |
| 483 | + } |
| 484 | + |
413 | 485 | /**
|
414 | 486 | * Prepare invoice for the order
|
415 | 487 | *
|
|
0 commit comments