Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreditCardTokenFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
14 use PHPUnit_Framework_MockObject_MockObject as MockObject;
15 
19 class CreditCardTokenFactoryTest extends \PHPUnit\Framework\TestCase
20 {
24  private $objectManager;
25 
29  private $paymentToken;
30 
34  private $factory;
35 
36  protected function setUp()
37  {
38  $objectManager = new ObjectManager($this);
39 
40  $tokenTypes = [
43  ];
44 
45  $this->paymentToken = $objectManager->getObject(PaymentToken::class);
46  $this->objectManager = $this->createMock(ObjectManagerInterface::class);
47 
48  $this->paymentTokenFactory = new PaymentTokenFactory($this->objectManager, $tokenTypes);
49  $this->factory = new CreditCardTokenFactory($this->objectManager, $this->paymentTokenFactory);
50  }
51 
55  public function testCreate()
56  {
57  $this->objectManager->expects(static::once())
58  ->method('create')
59  ->willReturn($this->paymentToken);
60 
61  $this->paymentToken->setType(\Magento\Vault\Api\Data\PaymentTokenFactoryInterface::TOKEN_TYPE_CREDIT_CARD);
62 
64  $paymentToken = $this->factory->create();
65  static::assertInstanceOf(PaymentTokenInterface::class, $paymentToken);
66  static::assertEquals(CreditCardTokenFactory::TOKEN_TYPE_CREDIT_CARD, $paymentToken->getType());
67  }
68 }