Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EditCurrencyCustomWebsiteTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\TestCase\Injectable;
11 use Magento\Mtf\TestStep\TestStepFactory;
12 use Magento\Mtf\Fixture\FixtureFactory;
13 
28 class EditCurrencyCustomWebsiteTest extends Injectable
29 {
35  private $fixtureFactory;
36 
42  private $stepFactory;
43 
51  public function __inject(
52  FixtureFactory $fixtureFactory,
53  TestStepFactory $stepFactory
54  ) {
55  $this->fixtureFactory = $fixtureFactory;
56  $this->stepFactory = $stepFactory;
57  }
58 
68  public function test($configData, array $product, Store $store, array $currencies = [])
69  {
70  // Preconditions
71  $this->stepFactory->create(
72  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
73  ['configData' => $configData]
74  )->run();
75 
76  $store->persist();
77  $product = $this->fixtureFactory->createByCode(
78  $product['fixture'],
79  ['dataset' => $product['dataset'], 'data' => ['website_ids' => [['store' => $store]]]]
80  );
81  $product->persist();
82  $websites = $product->getDataFieldConfig('website_ids')['source']->getWebsites();
83 
84  // Steps
85  $configFixture = $this->fixtureFactory->createByCode(
86  'configData',
87  [
88  'data' => [
89  'currency/options/allow' => [
90  'value' => $currencies[0]['allowedCurrencies']
91  ],
92  'currency/options/base' => [
93  'value' => $currencies[0]['baseCurrency']
94  ],
95  'currency/options/default' => [
96  'value' => $currencies[0]['defaultCurrency']
97  ],
98  'scope' => [
99  'fixture' => $websites[0],
100  'scope_type' => 'website',
101  'website_id' => $websites[0]->getWebsiteId(),
102  'set_level' => 'website',
103  ]
104  ]
105  ]
106  );
107  $configFixture->persist();
108 
109  return [
110  'product' => $product,
111  ];
112  }
113 
119  public function tearDown()
120  {
121  $this->stepFactory->create(
122  \Magento\Config\Test\TestStep\SetupConfigurationStep::class,
123  ['configData' => 'config_currency_symbols_usd, price_scope_website_rollback']
124  )->run();
125  }
126 }
test($configData, array $product, Store $store, array $currencies=[])
__inject(FixtureFactory $fixtureFactory, TestStepFactory $stepFactory)