Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SuiteDataArrayBuilder.php
Go to the documentation of this file.
1 <?php
6 namespace tests\unit\Util;
7 
11 
13 {
19  private $name;
20 
26  private $testActionBeforeName = 'testActionBefore';
27 
33  private $testActionAfterName = 'testActionAfter';
34 
40  private $beforeHook = [];
41 
47  private $afterHook = [];
48 
54  private $includes = [];
55 
61  private $excludes = [];
62 
68  public $testActionType = 'testAction';
69 
76  public function withName($name)
77  {
78  $this->name = $name;
79  return $this;
80  }
81 
88  public function includeTests($tests)
89  {
90  $this->includes = $this->appendEntriesToSuiteContents($this->includes, 'test', $tests);
91  return $this;
92  }
93 
100  public function excludeTests($tests)
101  {
102  $this->excludes = $this->appendEntriesToSuiteContents($this->excludes, 'test', $tests);
103  return $this;
104  }
105 
112  public function includeGroups($groups)
113  {
114  $this->includes = $this->appendEntriesToSuiteContents($this->includes, 'group', $groups);
115  return $this;
116  }
117 
124  public function excludeGroups($groups)
125  {
126  $this->excludes = $this->appendEntriesToSuiteContents($this->excludes, 'groups', $groups);
127  return $this;
128  }
129 
136  public function includeModules($modules)
137  {
138  $this->includes = $this->appendEntriesToSuiteContents($this->includes, 'module', $modules);
139  return $this;
140  }
141 
148  public function excludeModules($modules)
149  {
150  $this->excludes = $this->appendEntriesToSuiteContents($this->excludes, 'module', $modules);
151  return $this;
152  }
153 
163  private function appendEntriesToSuiteContents($currentContents, $type, $contents)
164  {
165  $newContents = $currentContents;
166  foreach ($contents as $entry) {
167  $newContents[$entry] = [
170  ];
171  }
172 
173  return $newContents;
174  }
175 
182  public function withAfterHook($afterHook = null)
183  {
184  if ($afterHook == null) {
185  $this->afterHook = [$this->testActionAfterName => [
187  ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testActionAfterName
188 
189  ]];
190  } else {
191  $this->afterHook = $afterHook;
192  }
193 
194  return $this;
195  }
196 
203  public function withBeforeHook($beforeHook = null)
204  {
205  if ($beforeHook == null) {
206  $this->beforeHook = [$this->testActionBeforeName => [
208  ActionObjectExtractor::TEST_STEP_MERGE_KEY => $this->testActionBeforeName
209  ]];
210  } else {
211  $this->beforeHook = $beforeHook;
212  }
213 
214  return $this;
215  }
216 
222  public function build()
223  {
224  return ['suites' => [
225  $this->name => [
226  SuiteObjectExtractor::NAME => $this->name,
227  TestObjectExtractor::TEST_BEFORE_HOOK => $this->beforeHook,
228  TestObjectExtractor::TEST_AFTER_HOOK => $this->afterHook,
229  SuiteObjectExtractor::INCLUDE_TAG_NAME => $this->includes,
230  SuiteObjectExtractor::EXCLUDE_TAG_NAME => $this->excludes
231  ]
232  ]];
233  }
234 }
$contents
Definition: website.php:14
$type
Definition: item.phtml:13