6 declare(strict_types=1);
18 private $paymentTokenMock;
23 private $paypalTokenFormatter;
28 private $tokenDetails = [
30 'maskedCC' =>
'4444************9999',
31 'expirationDate' =>
'07-07-2025' 39 $this->paymentTokenMock = $this->getMockBuilder(PaymentTokenInterface::class)
40 ->getMockForAbstractClass();
42 $this->paypalTokenFormatter =
new PaypalTokenFormatter();
50 $this->tokenDetails[
'type'] = key(PaypalTokenFormatter::$baseCardTypes);
51 $this->paymentTokenMock->expects($this->once())
52 ->method(
'getTokenDetails')
53 ->willReturn(json_encode($this->tokenDetails));
55 $formattedString = sprintf(
56 '%s: %s, %s: %s (%s: %s)',
58 reset(PaypalTokenFormatter::$baseCardTypes),
60 $this->tokenDetails[
'maskedCC'],
62 $this->tokenDetails[
'expirationDate']
65 self::assertEquals($formattedString, $this->paypalTokenFormatter->formatPaymentToken($this->paymentTokenMock));
73 $this->paymentTokenMock->expects($this->once())
74 ->method(
'getTokenDetails')
75 ->willReturn(json_encode($this->tokenDetails));
77 $formattedString = sprintf(
78 '%s: %s, %s: %s (%s: %s)',
80 $this->tokenDetails[
'type'],
82 $this->tokenDetails[
'maskedCC'],
84 $this->tokenDetails[
'expirationDate']
87 self::assertEquals($formattedString, $this->paypalTokenFormatter->formatPaymentToken($this->paymentTokenMock));
95 unset($this->tokenDetails[
'type']);
97 $this->paymentTokenMock->expects($this->once())
98 ->method(
'getTokenDetails')
99 ->willReturn(json_encode($this->tokenDetails));
100 self::expectException(
'\InvalidArgumentException');
102 $this->paypalTokenFormatter->formatPaymentToken($this->paymentTokenMock);