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 
17 use PHPUnit\Framework\TestCase;
18 
22 class InstantPurchaseTest extends TestCase
23 {
27  private $objectManager;
28 
29  public function setUp()
30  {
31  $this->objectManager = Bootstrap::getObjectManager();
32  }
33 
40  {
41  $option = $this->invokeTestInstantPurchaseOptionCalculation();
42 
43  $this->assertTrue($option->isAvailable());
44  $this->assertInstanceOf(PaymentTokenInterface::class, $option->getPaymentToken());
45  $this->assertInstanceOf(Address::class, $option->getShippingAddress());
46  $this->assertInstanceOf(Address::class, $option->getBillingAddress());
47  $this->assertInstanceOf(ShippingMethodInterface::class, $option->getShippingMethod());
48  }
49 
55  {
56  $option = $this->invokeTestInstantPurchaseOptionCalculation();
57  $this->assertFalse($option->isAvailable());
58  }
59 
67  {
68  $option = $this->invokeTestInstantPurchaseOptionCalculation();
69  $this->assertFalse($option->isAvailable());
70  }
71 
79  {
80  $option = $this->invokeTestInstantPurchaseOptionCalculation();
81  $this->assertFalse($option->isAvailable());
82  }
83 
89  {
90  $option = $this->invokeTestInstantPurchaseOptionCalculation();
91  $this->assertFalse($option->isAvailable());
92  }
93 
101  {
102  $option = $this->invokeTestInstantPurchaseOptionCalculation();
103  $this->assertFalse($option->isAvailable());
104  }
105 
113  {
114  $option = $this->invokeTestInstantPurchaseOptionCalculation();
115  $this->assertFalse($option->isAvailable());
116  }
117 
125  {
126  $option = $this->invokeTestInstantPurchaseOptionCalculation();
127  $this->assertFalse($option->isAvailable());
128  }
129 
135  private function invokeTestInstantPurchaseOptionCalculation(): InstantPurchaseOption
136  {
138  $instantPurchase = $this->objectManager->create(InstantPurchaseInterface::class);
139  $store = $this->getFixtureStore();
140  $customer = $this->getFixtureCustomer();
141  $option = $instantPurchase->getOption($store, $customer);
142  return $option;
143  }
144 
150  private function getFixtureStore(): Store
151  {
152  $repository = $this->objectManager->create(StoreRepositoryInterface::class);
153  $store = $repository->get('default');
154  return $store;
155  }
156 
162  private function getFixtureCustomer(): Customer
163  {
164  $repository = $this->objectManager->create(CustomerRepositoryInterface::class);
165  $customerData = $repository->getById(1);
166  $customer = $this->objectManager->create(Customer::class);
167  $customer->updateData($customerData);
168  return $customer;
169  }
170 }
$customerData
$customer
Definition: customers.php:11