-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathTestEntityExtractor.php
57 lines (50 loc) · 1.65 KB
/
TestEntityExtractor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Created by PhpStorm.
* User: imeron
* Date: 8/25/17
* Time: 11:11 AM
*/
namespace Magento\FunctionalTestingFramework\Test\Util;
use Robo\Exception\TaskExitException;
/**
* Class TestEntityExtractor
*/
class TestEntityExtractor extends BaseCestObjectExtractor
{
const TEST_STEP_ENTITY_CREATION = 'entity';
const TEST_ENTITY_CREATION_KEY = 'key';
const TEST_ENTITY_CREATION_VALUE = 'value';
const TEST_STEP_DATA_CREATION = 'createData';
/**
* TestEntityExtractor constructor.
*/
public function __construct()
{
// empty constructor
}
/**
* Extracts custom entity or data definitions from test actions.
* Returns array of entity data objects indexed by mergeKey, and an array of key-value pairs.
* @param array $testActions
* @return array $entityData
*/
public function extractTestEntities($testActions)
{
$testEntities = [];
foreach ($testActions as $actionName => $actionData) {
$entityData = [];
if ($actionData[TestEntityExtractor::NODE_NAME] === TestEntityExtractor::TEST_STEP_ENTITY_CREATION) {
foreach ($actionData as $key => $attribute) {
if (is_array($attribute)) {
$entityData[$attribute[TestEntityExtractor::TEST_ENTITY_CREATION_KEY]]
= $attribute[TestEntityExtractor::TEST_ENTITY_CREATION_VALUE];
unset($actionData[$key]);
}
}
$testEntities[$actionData[TestEntityExtractor::NAME]] = $entityData;
}
}
return $testEntities;
}
}