Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InstantPurchaseTest.php
Go to the documentation of this file.
1 <?php
7 
10 use PHPUnit\Framework\TestCase;
12 
16 class InstantPurchaseTest extends TestCase
17 {
21  private $objectManager;
22 
23  public function setUp()
24  {
25  $this->objectManager = Bootstrap::getObjectManager();
26  }
27 
33  public function testDefaultFormatterIsAppliedWhenBasicIntegration()
34  {
36  $customerSession = $this->objectManager->get(Session::class);
37  $customerSession->loginById(1);
38 
40  $customerDataSectionSource = $this->objectManager->get(InstantPurchase::class);
41  $data = $customerDataSectionSource->getSectionData();
42  $this->assertEquals(
43  'Fake Payment Method Vault',
44  $data['paymentToken']['summary'],
45  'Basic implementation returns provider title.'
46  );
47  }
48 
55  public function testCustomFormatterIsAppliedWhenComplexIntegration()
56  {
57  $this->objectManager->configure([
58  'StubFormatter' => [
59  'type' => StubPaymentTokenFormatter::class,
60  ],
61  ]);
63  $customerSession = $this->objectManager->get(Session::class);
64  $customerSession->loginById(1);
65 
67  $customerDataSectionSource = $this->objectManager->get(InstantPurchase::class);
68  $data = $customerDataSectionSource->getSectionData();
69  $this->assertEquals(
71  $data['paymentToken']['summary'],
72  'Complex implementation returns custom string.'
73  );
74  }
75 }