Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateTaxWithFptTest.php
Go to the documentation of this file.
1 <?php
8 
12 use Magento\Mtf\Fixture\FixtureFactory;
13 use Magento\Mtf\ObjectManager;
14 use Magento\Mtf\TestCase\Injectable;
15 
47 class CreateTaxWithFptTest extends Injectable
48 {
49  /* tags */
50  const MVP = 'no';
51  /* end tags */
52 
58  protected $fixtureFactory;
59 
66  public function __prepare(FixtureFactory $fixtureFactory)
67  {
68  $this->fixtureFactory = $fixtureFactory;
69  $customer = $fixtureFactory->createByCode('customer', ['dataset' => 'johndoe_with_addresses']);
70  $customer->persist();
71  $attributeSet = $this->fixtureFactory
72  ->createByCode('catalogAttributeSet', ['dataset' => 'custom_attribute_set_with_fpt']);
73  $attributeSet->persist();
74  return [
75  'customer' => $customer,
76  'attributeSet' => $attributeSet
77  ];
78  }
79 
86  protected function loginCustomer(Customer $customer)
87  {
88  $this->objectManager->create(
89  \Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class,
90  ['customer' => $customer]
91  )->run();
92  }
93 
103  public function test(
104  $productData,
105  $configData,
106  Customer $customer,
107  CatalogAttributeSet $attributeSet
108  ) {
109  $this->fixtureFactory->createByCode('taxRule', ['dataset' => 'tax_rule_default'])->persist();
110  $product = $this->fixtureFactory->createByCode(
111  'catalogProductSimple',
112  ['dataset' => $productData, 'data' => ['attribute_set_id' => ['attribute_set' => $attributeSet]]]
113  );
114  $product->persist();
115  $this->objectManager->create(
116  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
117  ['configData' => $configData]
118  )->run();
119  $this->loginCustomer($customer);
120 
121  return ['product' => $product];
122  }
123 
129  public function tearDown()
130  {
131  $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class)->run();
132  $this->objectManager->create(
133  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
134  ['configData' => 'default_tax_configuration,shipping_tax_class_taxable_goods_rollback']
135  )->run();
136  }
137 }
$customer
Definition: customers.php:11
test( $productData, $configData, Customer $customer, CatalogAttributeSet $attributeSet)
$productData