Skip to content

Commit

Permalink
PAYOSWXP-158: Simplify the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
momocode-de committed Nov 29, 2024
1 parent 350de26 commit 59a950f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 56 deletions.
54 changes: 6 additions & 48 deletions tests/EventListener/PayPalV2ExpressEventListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 10 additions & 8 deletions tests/PaymentHandler/PayonePaypalV2PaymentHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 59a950f

Please sign in to comment.