Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateTaxRuleStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Fixture\FixtureFactory;
10 use Magento\Mtf\TestStep\TestStepInterface;
11 
15 class CreateTaxRuleStep implements TestStepInterface
16 {
22  protected $taxRule;
23 
29  protected $fixtureFactory;
30 
36  protected $deleteAllTaxRule;
37 
46  public function __construct(FixtureFactory $fixtureFactory, DeleteAllTaxRulesStep $deleteTaxRule, $taxRule = null)
47  {
48  $this->fixtureFactory = $fixtureFactory;
49  $this->taxRule = $taxRule;
50  $this->deleteAllTaxRule = $deleteTaxRule;
51  }
52 
58  public function run()
59  {
60  $result['taxRule'] = null;
61  if ($this->taxRule !== null) {
62  $taxRuleDataSets = explode(',', $this->taxRule);
63  foreach ($taxRuleDataSets as $taxRuleDataSet) {
64  $taxRule = $this->fixtureFactory->createByCode(
65  'taxRule',
66  ['dataset' => $taxRuleDataSet]
67  );
68  $taxRule->persist();
69  $result['taxRule'] = $taxRule;
70  }
71  }
72 
73  return $result;
74  }
75 
81  public function cleanup()
82  {
83  if ($this->taxRule !== null) {
84  $this->deleteAllTaxRule->run();
85  }
86  }
87 }
__construct(FixtureFactory $fixtureFactory, DeleteAllTaxRulesStep $deleteTaxRule, $taxRule=null)