componentFactory = $this->getMockBuilder(TokenUiComponentInterfaceFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->tokenComponent = $this->getMockForAbstractClass(TokenUiComponentInterface::class); $this->urlBuilder = $this->getMockForAbstractClass(UrlInterface::class); $this->paymentToken = $this->getMockForAbstractClass(PaymentTokenInterface::class); $this->componentProvider = new TokenUiComponentProvider( $this->componentFactory, $this->urlBuilder ); } /** * @covers \Magento\Braintree\Model\Ui\PayPal\TokenUiComponentProvider::getComponentForToken */ public function testGetComponentForToken() { $tokenDetails = [ 'payerEmail' => 'john.doe@example.com' ]; $hash = '4g1mn4ew0vj23n2jf'; $this->paymentToken->expects(static::once()) ->method('getTokenDetails') ->willReturn(json_encode($tokenDetails)); $this->componentFactory->expects(static::once()) ->method('create') ->willReturn($this->tokenComponent); $this->paymentToken->expects(static::once()) ->method('getPublicHash') ->willReturn($hash); $this->urlBuilder->expects(static::once()) ->method('getUrl'); $actual = $this->componentProvider->getComponentForToken($this->paymentToken); static::assertEquals($this->tokenComponent, $actual); } }