/** * @param Http $request * @return PaymentTokenInterface|null */ private function getPaymentToken(Http $request) { $publicHash = $request->getPostValue(PaymentTokenInterface::PUBLIC_HASH); if ($publicHash === null) { return null; } return $this->paymentTokenManagement->getByPublicHash($publicHash, $this->customerSession->getCustomerId()); }
/** * Run test for getByGatewayToken method (return NULL) */ public function testGetByPublicHash() { $this->paymentTokenResourceModelMock->expects(self::once())->method('getByPublicHash')->with('some-not-exists-token', 1)->willReturn([]); $this->paymentTokenFactoryMock->expects(self::never())->method('create'); self::assertEquals(null, $this->paymentTokenManagement->getByPublicHash('some-not-exists-token', 1)); }