From 3ee8c3500be975627613c1d382fd57be9f3e7e9e Mon Sep 17 00:00:00 2001 From: jissereitsma <7670482+jissereitsma@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:59:41 +0000 Subject: [PATCH 1/2] Initial plan From c580b6538f230bcb1b5eb1e06327f78f66cf9a30 Mon Sep 17 00:00:00 2001 From: jissereitsma <7670482+jissereitsma@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:02:36 +0000 Subject: [PATCH 2/2] Fix PHPStan missing sales test helpers Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- Test/Integration/Email/SalesEmailTest.php | 27 ++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Test/Integration/Email/SalesEmailTest.php b/Test/Integration/Email/SalesEmailTest.php index 2bc8305..eecdc29 100644 --- a/Test/Integration/Email/SalesEmailTest.php +++ b/Test/Integration/Email/SalesEmailTest.php @@ -13,6 +13,13 @@ use Magento\Checkout\Test\Fixture\SetShippingAddress as SetShippingAddressFixture; use Magento\Quote\Test\Fixture\AddProductToCart as AddProductToCartFixture; use Magento\Quote\Test\Fixture\GuestCart as GuestCartFixture; +use Magento\Sales\Api\CreditmemoRepositoryInterface; +use Magento\Sales\Api\Data\CreditmemoInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\ShipmentInterface; +use Magento\Sales\Api\RefundOrderInterface; +use Magento\Sales\Api\ShipmentRepositoryInterface; +use Magento\Sales\Api\ShipOrderInterface; use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender; @@ -73,7 +80,7 @@ public function testShipmentEmailShowsValue(): void { $cartId = $this->getCartId(); $this->saveQuoteExtended($cartId, ['example_field' => self::VALUE]); - $shipment = $this->createShipment($this->placeOrder($cartId)); + $shipment = $this->createShipmentForEmail($this->placeOrder($cartId)); $body = $this->sendAndGetBody(fn () => $this->get(ShipmentSender::class)->send($shipment, true)); @@ -88,7 +95,7 @@ public function testCreditmemoEmailShowsValue(): void $this->saveQuoteExtended($cartId, ['example_field' => self::VALUE]); $order = $this->placeOrder($cartId); $this->createInvoice($order); - $creditmemo = $this->createCreditmemo($order); + $creditmemo = $this->createCreditmemoForEmail($order); $body = $this->sendAndGetBody(fn () => $this->get(CreditmemoSender::class)->send($creditmemo, true)); @@ -99,7 +106,7 @@ public function testCreditmemoEmailShowsValue(): void public function testShipmentEmailHidesEmptyValue(): void { - $shipment = $this->createShipment($this->placeOrder($this->getCartId())); + $shipment = $this->createShipmentForEmail($this->placeOrder($this->getCartId())); $body = $this->sendAndGetBody(fn () => $this->get(ShipmentSender::class)->send($shipment, true)); @@ -128,6 +135,20 @@ private function sendAndGetBody(callable $send): string return quoted_printable_decode($message->getBodyText()); } + private function createShipmentForEmail(OrderInterface $order): ShipmentInterface + { + $shipmentId = $this->om()->get(ShipOrderInterface::class)->execute((int)$order->getEntityId()); + + return $this->om()->get(ShipmentRepositoryInterface::class)->get((int)$shipmentId); + } + + private function createCreditmemoForEmail(OrderInterface $order): CreditmemoInterface + { + $creditmemoId = $this->om()->get(RefundOrderInterface::class)->execute((int)$order->getEntityId()); + + return $this->om()->get(CreditmemoRepositoryInterface::class)->get((int)$creditmemoId); + } + private function get(string $className): object { return Bootstrap::getObjectManager()->get($className);