getPaymentNonceCommandMock = $this->createMock(GetPaymentNonceCommand::class); $this->paymentTokenMock = $this->createMock(PaymentTokenInterface::class); $this->arrayResultMock = $this->createMock(ArrayResult::class); $this->paymentAdditionalInformationProvider = new PaymentAdditionalInformationProvider( $this->getPaymentNonceCommandMock ); } /** * Test getAdditionalInformation method * * @return void */ public function testGetAdditionalInformation() { $customerId = 15; $publicHash = '3n4b7sn48g'; $paymentMethodNonce = 'test'; $this->paymentTokenMock->expects($this->once())->method('getCustomerId')->willReturn($customerId); $this->paymentTokenMock->expects($this->once())->method('getPublicHash')->willReturn($publicHash); $this->getPaymentNonceCommandMock->expects($this->once())->method('execute')->with([ PaymentTokenInterface::CUSTOMER_ID => $customerId, PaymentTokenInterface::PUBLIC_HASH => $publicHash, ])->willReturn($this->arrayResultMock); $this->arrayResultMock->expects($this->once())->method('get') ->willReturn(['paymentMethodNonce' => $paymentMethodNonce]); $expected = [ 'payment_method_nonce' => $paymentMethodNonce, ]; $actual = $this->paymentAdditionalInformationProvider->getAdditionalInformation($this->paymentTokenMock); self::assertEquals($expected, $actual); } }