Skip to content

Commit 5fd746c

Browse files
committed
MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality
1 parent f5dfd24 commit 5fd746c

File tree

2 files changed

+17
-58
lines changed

2 files changed

+17
-58
lines changed

src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ class MagentoAllureAdapter extends AllureCodeception
4949
*/
5050
private $atInvisibleSteps = false;
5151

52-
/**
53-
* Boolean array to store status of previous invisible steps
54-
*
55-
* @var array
56-
*/
57-
private $invisibleStepStatus = [];
58-
5952
/**
6053
* Array of group values passed to test runner command
6154
*
@@ -137,9 +130,6 @@ private function sanitizeGroupName($group)
137130
* @param StepEvent $stepEvent
138131
* @return void
139132
* @throws \Yandex\Allure\Adapter\AllureException
140-
*
141-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
142-
* @SuppressWarnings(PHPMD.NPathComplexity)
143133
*/
144134
public function stepBefore(StepEvent $stepEvent)
145135
{
@@ -198,27 +188,18 @@ public function stepBefore(StepEvent $stepEvent)
198188
*/
199189
public function stepAfter(StepEvent $stepEvent = null)
200190
{
201-
// Store invisible step status if step is in INVISIBLE_STEP_ACTIONS
202-
if ($this->atInvisibleSteps && $stepEvent->getStep()->hasFailed()) {
203-
$this->invisibleStepStatus[] = false;
204-
return;
205-
} elseif ($this->atInvisibleSteps) {
206-
$this->invisibleStepStatus[] = true;
207-
return;
208-
} else {
209-
// Check previous invisible steps status
210-
$invisibleStepsPassed = true;
211-
foreach ($this->invisibleStepStatus as $pass) {
212-
if (!$pass) {
213-
$invisibleStepsPassed = false;
214-
break;
215-
}
216-
}
217-
$this->invisibleStepStatus = [];
218-
if ($stepEvent->getStep()->hasFailed() || !$invisibleStepsPassed) {
219-
$this->getLifecycle()->fire(new StepFailedEvent());
191+
// Simply return if step is INVISIBLE_STEP_ACTIONS
192+
if ($this->atInvisibleSteps) {
193+
if ($stepEvent->getStep()->hasFailed()) {
194+
$this->atInvisibleSteps = false;
220195
}
196+
return;
221197
}
198+
199+
if ($stepEvent->getStep()->hasFailed()) {
200+
$this->getLifecycle()->fire(new StepFailedEvent());
201+
}
202+
222203
$this->getLifecycle()->fire(new StepFinishedEvent());
223204
}
224205

src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ class Console extends \Codeception\Subscriber\Console
3939
*/
4040
private $atInvisibleSteps = false;
4141

42-
/**
43-
* Boolean array to store status of previous invisible steps
44-
*
45-
* @var array
46-
*/
47-
private $invisibleStepStatus = [];
48-
4942
/**
5043
* Console constructor. Parent constructor requires codeception CLI options, and does not have its own configs.
5144
* Constructor is only different than parent due to the way Codeception instantiates Extensions.
@@ -65,8 +58,6 @@ public function __construct($extensionOptions = [], $options = [])
6558
*
6659
* @param StepEvent $e
6760
* @return void
68-
*
69-
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
7061
*/
7162
public function beforeStep(StepEvent $e)
7263
{
@@ -107,27 +98,14 @@ public function beforeStep(StepEvent $e)
10798
*/
10899
public function afterStep(StepEvent $e)
109100
{
110-
// Store invisible step status if step is in INVISIBLE_STEP_ACTIONS
111-
if ($this->atInvisibleSteps && $e->getStep()->hasFailed()) {
112-
$this->invisibleStepStatus[] = false;
113-
return;
114-
} elseif ($this->atInvisibleSteps) {
115-
$this->invisibleStepStatus[] = true;
116-
return;
117-
} else {
118-
// Check previous invisible steps status
119-
$invisibleStepsPassed = true;
120-
foreach ($this->invisibleStepStatus as $pass) {
121-
if (!$pass) {
122-
$invisibleStepsPassed = false;
123-
break;
124-
}
125-
}
126-
$this->invisibleStepStatus = [];
101+
// Do usual after step if step is not INVISIBLE_STEP_ACTIONS
102+
if (!$this->atInvisibleSteps) {
127103
parent::afterStep($e);
128-
if ($e->getStep()->hasFailed() || !$invisibleStepsPassed) {
129-
$this->actionGroupStepKey = null;
130-
}
104+
}
105+
106+
if ($e->getStep()->hasFailed()) {
107+
$this->actionGroupStepKey = null;
108+
$this->atInvisibleSteps = false;
131109
}
132110
}
133111

0 commit comments

Comments
 (0)