Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetupConfigurationStep.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\Fixture\FixtureFactory;
11 use Magento\Mtf\TestStep\TestStepInterface;
13 
17 class SetupConfigurationStep implements TestStepInterface
18 {
24  protected $fixtureFactory;
25 
31  protected $configData;
32 
38  protected $rollback;
39 
45  protected $flushCache;
46 
52  private $cache;
53 
63  public function __construct(
64  FixtureFactory $fixtureFactory,
65  Cache $cache,
66  $configData = null,
67  $rollback = false,
68  $flushCache = false
69  ) {
70  $this->fixtureFactory = $fixtureFactory;
71  $this->configData = $configData;
72  $this->rollback = $rollback;
73  $this->flushCache = $flushCache;
74  $this->cache = $cache;
75  }
76 
82  public function run()
83  {
84  if ($this->configData === null) {
85  return [];
86  }
87  $prefix = ($this->rollback == false) ? '' : '_rollback';
88 
89  $configData = array_map('trim', explode(',', $this->configData));
90  $result = [];
91 
92  foreach ($configData as $configDataSet) {
94  $config = $this->fixtureFactory->createByCode('configData', ['dataset' => $configDataSet . $prefix]);
95  if ($config->hasData('section')) {
96  $config->persist();
97  $result = array_merge($result, $config->getSection());
98  }
99  if ($this->flushCache) {
100  $this->cache->flush();
101  }
102  }
103  $config = $this->fixtureFactory->createByCode('configData', ['data' => $result]);
104 
105  return ['config' => $config];
106  }
107 
113  public function cleanup()
114  {
115  $this->rollback = true;
116  $this->run();
117  }
118 }
__construct(FixtureFactory $fixtureFactory, Cache $cache, $configData=null, $rollback=false, $flushCache=false)
$config
Definition: fraud_order.php:17
$prefix
Definition: name.phtml:25