From 3e8f94ccdfac71da3c23698f7560e6f96a9f2eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Wed, 4 Dec 2024 15:18:28 +0100 Subject: [PATCH] Fix tests --- .../Controller/HandleWebhookActionTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Functional/Controller/HandleWebhookActionTest.php b/tests/Functional/Controller/HandleWebhookActionTest.php index 54044ad..79ab40b 100644 --- a/tests/Functional/Controller/HandleWebhookActionTest.php +++ b/tests/Functional/Controller/HandleWebhookActionTest.php @@ -4,6 +4,8 @@ namespace Tests\Setono\SyliusPeakPlugin\Functional\Controller; +use Setono\PeakWMS\Client\Client; +use Setono\PeakWMS\DataTransferObject\Stock\Stock; use Setono\SyliusPeakPlugin\Model\OrderInterface; use Sylius\Component\Core\Model\OrderItemInterface; use Sylius\Component\Core\Model\ProductVariantInterface; @@ -16,6 +18,9 @@ use Sylius\Component\Resource\Factory\FactoryInterface; use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\HttpClient\MockHttpClient; +use Symfony\Component\HttpClient\Psr18Client; +use Symfony\Component\HttpClient\Response\JsonMockResponse; final class HandleWebhookActionTest extends WebTestCase { @@ -31,6 +36,16 @@ protected function setUp(): void */ public function it_handles_stock_adjustments(): void { + $httpClient = new MockHttpClient([new JsonMockResponse([new Stock( + productId: 'Everyday_white_basic_T_Shirt', + variantId: 'Everyday_white_basic_T_Shirt-variant-0', + quantity: 2, + reservedQuantity: 0, + )])]); + + $peakClient = self::getContainer()->get(Client::class); + $peakClient->setHttpClient(new Psr18Client($httpClient)); + self::$client->request( method: 'POST', uri: '/peak/webhook?name=100', @@ -46,6 +61,8 @@ public function it_handles_stock_adjustments(): void ); self::assertResponseStatusCodeSame(204); + + // todo assert that the actual on hand value on the variant is changed } /**