Skip to content

Commit be3bd6e

Browse files
committed
MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality
- work around MQE-1904
1 parent c1964dc commit be3bd6e

File tree

2 files changed

+139
-37
lines changed

2 files changed

+139
-37
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,9 @@
2020
*/
2121
class MagentoActionProxies extends CodeceptionModule
2222
{
23-
/**
24-
* PersistedObjectHandler instance
25-
*
26-
* @var PersistedObjectHandler
27-
*/
28-
private static $persistHandler = null;
29-
3023
/**
3124
* Create an entity
25+
* TODO: un-comment this function after MQE-1904
3226
*
3327
* @param string $key StepKey of the createData action.
3428
* @param string $scope
@@ -38,6 +32,7 @@ class MagentoActionProxies extends CodeceptionModule
3832
* @param string $storeCode
3933
* @return void
4034
*/
35+
/*
4136
public function createEntity(
4237
$key,
4338
$scope,
@@ -46,11 +41,7 @@ public function createEntity(
4641
$overrideFields = [],
4742
$storeCode = ''
4843
) {
49-
if (!self::$persistHandler) {
50-
self::$persistHandler = PersistedObjectHandler::getInstance();
51-
}
52-
53-
self::$persistHandler->createEntity(
44+
PersistedObjectHandler::getInstance()->createEntity(
5445
$key,
5546
$scope,
5647
$entity,
@@ -59,32 +50,31 @@ public function createEntity(
5950
$storeCode
6051
);
6152
}
62-
53+
*/
6354
/**
6455
* Retrieves and updates a previously created entity
56+
* TODO: un-comment this function after MQE-1904
6557
*
6658
* @param string $key StepKey of the createData action.
6759
* @param string $scope
6860
* @param string $updateEntity Name of the static XML data to update the entity with.
6961
* @param array $dependentObjectKeys StepKeys of other createData actions that are required.
7062
* @return void
7163
*/
64+
/*
7265
public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = [])
7366
{
74-
if (!self::$persistHandler) {
75-
self::$persistHandler = PersistedObjectHandler::getInstance();
76-
}
77-
78-
self::$persistHandler->updateEntity(
67+
PersistedObjectHandler::getInstance()->updateEntity(
7968
$key,
8069
$scope,
8170
$updateEntity,
8271
$dependentObjectKeys
8372
);
8473
}
85-
74+
*/
8675
/**
8776
* Performs GET on given entity and stores entity for use
77+
* TODO: un-comment this function after MQE-1904
8878
*
8979
* @param string $key StepKey of getData action.
9080
* @param string $scope
@@ -94,13 +84,10 @@ public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys =
9484
* @param integer $index
9585
* @return void
9686
*/
87+
/*
9788
public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $storeCode = '', $index = null)
9889
{
99-
if (!self::$persistHandler) {
100-
self::$persistHandler = PersistedObjectHandler::getInstance();
101-
}
102-
103-
self::$persistHandler->getEntity(
90+
PersistedObjectHandler::getInstance()->getEntity(
10491
$key,
10592
$scope,
10693
$entity,
@@ -109,49 +96,48 @@ public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $sto
10996
$index
11097
);
11198
}
112-
99+
*/
113100
/**
114101
* Retrieves and deletes a previously created entity
102+
* TODO: un-comment this function after MQE-1904
115103
*
116104
* @param string $key StepKey of the createData action.
117105
* @param string $scope
118106
* @return void
119107
*/
108+
/*
120109
public function deleteEntity($key, $scope)
121110
{
122-
if (!self::$persistHandler) {
123-
self::$persistHandler = PersistedObjectHandler::getInstance();
124-
}
125-
126-
self::$persistHandler->deleteEntity($key, $scope);
111+
PersistedObjectHandler::getInstance()->deleteEntity($key, $scope);
127112
}
128-
113+
*/
129114
/**
130115
* Retrieves a field from an entity, according to key and scope given
116+
* TODO: un-comment this function after MQE-1904
131117
*
132118
* @param string $stepKey
133119
* @param string $field
134120
* @param string $scope
135121
* @return string
136122
*/
123+
/*
137124
public function retrieveEntityField($stepKey, $field, $scope)
138125
{
139-
if (!self::$persistHandler) {
140-
self::$persistHandler = PersistedObjectHandler::getInstance();
141-
}
142-
143-
return self::$persistHandler->retrieveEntityField($stepKey, $field, $scope);
126+
return PersistedObjectHandler::getInstance()->retrieveEntityField($stepKey, $field, $scope);
144127
}
145-
128+
*/
146129
/**
147130
* Get encrypted value by key
131+
* TODO: un-comment this function after MQE-1904
148132
*
149133
* @param string $key
150134
* @return string|null
151135
* @throws TestFrameworkException
152136
*/
137+
/*
153138
public function getSecret($key)
154139
{
155140
return CredentialStore::getInstance()->getSecret($key);
156141
}
142+
*/
157143
}

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig;
2828
use Facebook\WebDriver\Remote\RemoteWebDriver;
2929
use Facebook\WebDriver\Exception\WebDriverCurlException;
30+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;
3031

3132
/**
3233
* MagentoWebDriver module provides common Magento web actions through Selenium WebDriver.
@@ -47,6 +48,7 @@
4748
* ```
4849
*
4950
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
51+
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
5052
*/
5153
class MagentoWebDriver extends WebDriver
5254
{
@@ -904,4 +906,118 @@ private function curlExecMagentoCLI($command, $timeout, $arguments): string
904906

905907
return $response;
906908
}
909+
910+
/**
911+
* Create an entity
912+
* TODO: remove this function after MQE-1904
913+
*
914+
* @param string $key StepKey of the createData action.
915+
* @param string $scope
916+
* @param string $entity Name of xml entity to create.
917+
* @param array $dependentObjectKeys StepKeys of other createData actions that are required.
918+
* @param array $overrideFields Array of FieldName => Value of override fields.
919+
* @param string $storeCode
920+
* @return void
921+
*/
922+
public function createEntity(
923+
$key,
924+
$scope,
925+
$entity,
926+
$dependentObjectKeys = [],
927+
$overrideFields = [],
928+
$storeCode = ''
929+
) {
930+
PersistedObjectHandler::getInstance()->createEntity(
931+
$key,
932+
$scope,
933+
$entity,
934+
$dependentObjectKeys,
935+
$overrideFields,
936+
$storeCode
937+
);
938+
}
939+
940+
/**
941+
* Retrieves and updates a previously created entity
942+
* TODO: remove this function after MQE-1904
943+
*
944+
* @param string $key StepKey of the createData action.
945+
* @param string $scope
946+
* @param string $updateEntity Name of the static XML data to update the entity with.
947+
* @param array $dependentObjectKeys StepKeys of other createData actions that are required.
948+
* @return void
949+
*/
950+
public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = [])
951+
{
952+
PersistedObjectHandler::getInstance()->updateEntity(
953+
$key,
954+
$scope,
955+
$updateEntity,
956+
$dependentObjectKeys
957+
);
958+
}
959+
960+
/**
961+
* Performs GET on given entity and stores entity for use
962+
* TODO: remove this function after MQE-1904
963+
*
964+
* @param string $key StepKey of getData action.
965+
* @param string $scope
966+
* @param string $entity Name of XML static data to use.
967+
* @param array $dependentObjectKeys StepKeys of other createData actions that are required.
968+
* @param string $storeCode
969+
* @param integer $index
970+
* @return void
971+
*/
972+
public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $storeCode = '', $index = null)
973+
{
974+
PersistedObjectHandler::getInstance()->getEntity(
975+
$key,
976+
$scope,
977+
$entity,
978+
$dependentObjectKeys,
979+
$storeCode,
980+
$index
981+
);
982+
}
983+
984+
/**
985+
* Retrieves and deletes a previously created entity
986+
* TODO: remove this function after MQE-1904
987+
*
988+
* @param string $key StepKey of the createData action.
989+
* @param string $scope
990+
* @return void
991+
*/
992+
public function deleteEntity($key, $scope)
993+
{
994+
PersistedObjectHandler::getInstance()->deleteEntity($key, $scope);
995+
}
996+
997+
/**
998+
* Retrieves a field from an entity, according to key and scope given
999+
* TODO: remove this function after MQE-1904
1000+
*
1001+
* @param string $stepKey
1002+
* @param string $field
1003+
* @param string $scope
1004+
* @return string
1005+
*/
1006+
public function retrieveEntityField($stepKey, $field, $scope)
1007+
{
1008+
return PersistedObjectHandler::getInstance()->retrieveEntityField($stepKey, $field, $scope);
1009+
}
1010+
1011+
/**
1012+
* Get encrypted value by key
1013+
* TODO: remove this function after MQE-1904
1014+
*
1015+
* @param string $key
1016+
* @return string|null
1017+
* @throws TestFrameworkException
1018+
*/
1019+
public function getSecret($key)
1020+
{
1021+
return CredentialStore::getInstance()->getSecret($key);
1022+
}
9071023
}

0 commit comments

Comments
 (0)