From 59a950f344fb1308ef79a344fcf3e7a98e4bd5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20M=C3=BCller?= Date: Fri, 29 Nov 2024 22:11:24 +0100 Subject: [PATCH] PAYOSWXP-158: Simplify the tests --- .../PayPalV2ExpressEventListenerTest.php | 54 +++---------------- .../PayonePaypalV2PaymentHandlerTest.php | 18 ++++--- 2 files changed, 16 insertions(+), 56 deletions(-) diff --git a/tests/EventListener/PayPalV2ExpressEventListenerTest.php b/tests/EventListener/PayPalV2ExpressEventListenerTest.php index 56937b7a..a44e5d7d 100644 --- a/tests/EventListener/PayPalV2ExpressEventListenerTest.php +++ b/tests/EventListener/PayPalV2ExpressEventListenerTest.php @@ -57,24 +57,10 @@ public function testItAddsExpressButtonDataExtension(string $eventClass, string ]); $activePaymentMethodsLoader = $this->createMock(ActivePaymentMethodsLoaderInterface::class); - $activePaymentMethodsLoader - ->expects(static::once()) - ->method('getActivePaymentMethodIds') - ->with( - static::equalTo($salesChannelContext) - ) - ->willReturn($activePaymentMethodIds) - ; + $activePaymentMethodsLoader->method('getActivePaymentMethodIds')->willReturn($activePaymentMethodIds); $configReader = $this->createMock(ConfigReaderInterface::class); - $configReader - ->expects(static::once()) - ->method('read') - ->with( - static::equalTo($salesChannelContext->getSalesChannelId()) - ) - ->willReturn($configuration) - ; + $configReader->method('read')->willReturn($configuration); $router = $this->createMock(RouterInterface::class); $logger = $this->createMock(LoggerInterface::class); @@ -114,20 +100,9 @@ public function testItNotAddsExpressButtonDataExtensionBecausePaymentMethodIsNot $request->setLocale('de-DE'); $activePaymentMethodsLoader = $this->createMock(ActivePaymentMethodsLoaderInterface::class); - $activePaymentMethodsLoader - ->expects(static::once()) - ->method('getActivePaymentMethodIds') - ->with( - static::equalTo($salesChannelContext) - ) - ->willReturn($activePaymentMethodIds) - ; + $activePaymentMethodsLoader->method('getActivePaymentMethodIds')->willReturn($activePaymentMethodIds); $configReader = $this->createMock(ConfigReaderInterface::class); - $configReader - ->expects(static::never()) - ->method('read') - ; $router = $this->createMock(RouterInterface::class); $logger = $this->createMock(LoggerInterface::class); @@ -169,32 +144,15 @@ public function testItNotAddsExpressButtonDataExtensionBecauseMerchantIdIsMissin ]); $activePaymentMethodsLoader = $this->createMock(ActivePaymentMethodsLoaderInterface::class); - $activePaymentMethodsLoader - ->expects(static::once()) - ->method('getActivePaymentMethodIds') - ->with( - static::equalTo($salesChannelContext) - ) - ->willReturn($activePaymentMethodIds) - ; + $activePaymentMethodsLoader->method('getActivePaymentMethodIds')->willReturn($activePaymentMethodIds); $configReader = $this->createMock(ConfigReaderInterface::class); - $configReader - ->expects(static::once()) - ->method('read') - ->with( - static::equalTo($salesChannelContext->getSalesChannelId()) - ) - ->willReturn($configuration) - ; + $configReader->method('read')->willReturn($configuration); $router = $this->createMock(RouterInterface::class); $logger = $this->createMock(LoggerInterface::class); - $logger - ->expects(static::once()) - ->method('warning') - ; + $logger->expects(static::once())->method('warning'); $listener = new PayPalV2ExpressEventListener( $activePaymentMethodsLoader, diff --git a/tests/PaymentHandler/PayonePaypalV2PaymentHandlerTest.php b/tests/PaymentHandler/PayonePaypalV2PaymentHandlerTest.php index ce898612..c7462fd3 100644 --- a/tests/PaymentHandler/PayonePaypalV2PaymentHandlerTest.php +++ b/tests/PaymentHandler/PayonePaypalV2PaymentHandlerTest.php @@ -34,21 +34,23 @@ public function testItPerformsPaymentAndReturnsCorrectRedirectUrl(): void $dataBag = new RequestDataBag(); $client = $this->createMock(PayoneClientInterface::class); - $client->expects(static::once())->method('request')->willReturn( - [ + $client + ->method('request') + ->willReturn([ 'status' => 'test-status', 'txid' => '', 'userid' => '', - ] - ); + ]) + ; $requestFactory = $this->createMock(RequestParameterFactory::class); - $requestFactory->expects(static::once())->method('getRequestParameter')->willReturn( - [ + $requestFactory + ->method('getRequestParameter') + ->willReturn([ 'request' => '', 'successurl' => 'test-url', - ] - ); + ]) + ; $paymentHandler = $this->getPaymentHandler($client, $dataBag, $requestFactory); $paymentTransaction = $this->getPaymentTransaction(