Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TestDataArrayBuilder.php
Go to the documentation of this file.
1 <?php
7 namespace tests\unit\Util;
8 
12 
14 {
20  public $testName = 'testTest';
21 
27  public $filename = null;
28 
34  public $testActionBeforeName = 'testActionBefore';
35 
41  public $testActionAfterName = 'testActionAfter';
42 
48  public $testActionFailedName = 'testActionFailed';
49 
55  public $testTestActionName = 'testActionInTest';
56 
62  public $testActionType = 'testAction';
63 
67  private $annotations = [];
68 
72  private $beforeHook = [];
73 
77  private $afterHook = [];
78 
82  private $failedHook = [];
83 
87  private $testActions = [];
88 
92  private $testReference = null;
93 
98  public function withName($name)
99  {
100  $this->testName = $name;
101  return $this;
102  }
103 
110  public function withAnnotations($annotations = null)
111  {
112  if ($annotations == null) {
113  $this->annotations = ['group' => [['value' => 'test']]];
114  } else {
115  $this->annotations = $annotations;
116  }
117 
118  return $this;
119  }
120 
127  public function withBeforeHook($beforeHook = null)
128  {
129  if ($beforeHook == null) {
130  $this->beforeHook = [$this->testActionBeforeName => [
133  ]];
134  } else {
135  $this->beforeHook = $beforeHook;
136  }
137 
138  return $this;
139  }
140 
147  public function withAfterHook($afterHook = null)
148  {
149  if ($afterHook == null) {
150  $this->afterHook = [$this->testActionAfterName => [
153 
154  ]];
155  } else {
156  $this->afterHook = $afterHook;
157  }
158 
159  return $this;
160  }
161 
168  public function withFailedHook($failedHook = null)
169  {
170  if ($failedHook == null) {
171  $this->failedHook = [$this->testActionFailedName => [
174 
175  ]];
176  } else {
177  $this->failedHook = $failedHook;
178  }
179 
180  return $this;
181  }
182 
189  public function withTestActions($actions = null)
190  {
191  if ($actions == null) {
192  $this->testActions = [$this->testTestActionName => [
195  ]];
196  } else {
197  $this->testActions = $actions;
198  }
199 
200  return $this;
201  }
202 
208  public function withFileName($filename = null)
209  {
210  if ($filename == null) {
211  $this->filename =
212  "/magento2-functional-testing-framework/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml";
213  } else {
214  $this->filename = $filename;
215  }
216 
217  return $this;
218  }
219 
226  public function withTestReference($reference = null)
227  {
228  if ($reference != null) {
229  $this->testReference = $reference;
230  }
231 
232  return $this;
233  }
234 
240  public function build()
241  {
242  // return a static data array representing a single test
243  return [$this->testName => array_merge(
244  [
245  TestObjectExtractor::NAME => $this->testName,
246  TestObjectExtractor::TEST_ANNOTATIONS => $this->annotations,
247  TestObjectExtractor::TEST_BEFORE_HOOK => $this->beforeHook,
248  TestObjectExtractor::TEST_AFTER_HOOK => $this->afterHook,
249  TestObjectExtractor::TEST_FAILED_HOOK => $this->failedHook,
250  "filename" => $this->filename,
251  "extends" => $this->testReference
252  ],
253  $this->testActions
254  )];
255  }
256 }
if(!isset($_GET['name'])) $name
Definition: log.php:14