Skip to content

Commit db0a41e

Browse files
committed
MQE-345:[DevOps] [Customizability] Create suite schema declaration and supporting interpretation
- fix for codesniff tests
1 parent b18fbc2 commit db0a41e

File tree

9 files changed

+83
-14
lines changed

9 files changed

+83
-14
lines changed

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/Curl/FrontendExecutor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected function setCookies()
132132
* @param string $url
133133
* @param array $data
134134
* @param string $method
135-
* @param mixed $headers
135+
* @param array $headers
136136
* @return void
137137
* @throws TestFrameworkException
138138
*/
@@ -190,7 +190,7 @@ public function read($successRegex = null, $returnRegex = null)
190190
* Add additional option to cURL.
191191
*
192192
* @param int $option the CURLOPT_* constants
193-
* @param mixed $value
193+
* @param int|string|bool|array $value
194194
* @return void
195195
*/
196196
public function addOption($option, $value)

src/Magento/FunctionalTestingFramework/Suite/Handlers/SuiteObjectHandler.php

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class SuiteObjectHandler implements ObjectHandlerInterface
4343
*/
4444
private $suiteObjects;
4545

46+
/**
47+
* SuiteObjectHandler constructor.
48+
*/
4649
private function __construct()
4750
{
4851
// empty constructor
@@ -87,12 +90,23 @@ public function getAllObjects()
8790
return $this->suiteObjects;
8891
}
8992

93+
/**
94+
* Method to parse all suite data xml into objects.
95+
*
96+
* @return void
97+
*/
9098
private function initSuiteData()
9199
{
92100
$suiteDataParser = ObjectManagerFactory::getObjectManager()->create(SuiteDataParser::class);
93101
$this->suiteObjects = $this->parseSuiteDataIntoObjects($suiteDataParser->readSuiteData());
94102
}
95103

104+
/**
105+
* Takes an array of parsed xml and converts into an array of suite objects.
106+
*
107+
* @param array $parsedSuiteData
108+
* @return array
109+
*/
96110
private function parseSuiteDataIntoObjects($parsedSuiteData)
97111
{
98112
$suiteObjects = [];
@@ -114,7 +128,6 @@ private function parseSuiteDataIntoObjects($parsedSuiteData)
114128
$includeCests = $includeCests + $this->extractGroups($groupCestsToInclude);
115129
$excludeCests = $excludeCests + $this->extractGroups($groupCestsToExclude);
116130

117-
118131
// get tests by path (dir or file)
119132
if (array_key_exists(self::MODULE_TAG_NAME, $groupCestsToInclude)) {
120133
$includeCests = array_merge(
@@ -141,6 +154,12 @@ private function parseSuiteDataIntoObjects($parsedSuiteData)
141154
return $suiteObjects;
142155
}
143156

157+
/**
158+
* Takes an array of Cests/Tests and resolves names into corresponding Cest/Test objects.
159+
*
160+
* @param array $suiteTestData
161+
* @return array
162+
*/
144163
private function extractRelevantTests($suiteTestData)
145164
{
146165
$relevantCests = [];
@@ -174,6 +193,12 @@ private function extractRelevantTests($suiteTestData)
174193
return $relevantCests;
175194
}
176195

196+
/**
197+
* Takes an array of group names and resolves to Cest/Test objects.
198+
*
199+
* @param array $suiteData
200+
* @return array
201+
*/
177202
private function extractGroups($suiteData)
178203
{
179204
$cestsByGroup = [];
@@ -188,6 +213,12 @@ private function extractGroups($suiteData)
188213
return $cestsByGroup;
189214
}
190215

216+
/**
217+
* Takes an array of modules/files and resolves to an array of cest objects.
218+
*
219+
* @param array $suitePathData
220+
* @return array
221+
*/
191222
private function extractModuleAndFiles($suitePathData)
192223
{
193224
$cestsByModule = [];
@@ -203,6 +234,14 @@ private function extractModuleAndFiles($suitePathData)
203234
return $cestsByModule;
204235
}
205236

237+
/**
238+
* Takes a filepath (and optionally a module name) and resolves to a cest object.
239+
*
240+
* @param string $filename
241+
* @param null $moduleName
242+
* @return CestObject
243+
* @throws Exception
244+
*/
206245
private function resolveFilePathCestName($filename, $moduleName = null)
207246
{
208247
$filepath = $filename;
@@ -225,6 +264,12 @@ private function resolveFilePathCestName($filename, $moduleName = null)
225264
return CestObjectHandler::getInstance()->getObject($cestName);
226265
}
227266

267+
/**
268+
* Takes a single module name and resolves to an array of cests contained within specified module.
269+
*
270+
* @param string $moduleName
271+
* @return array
272+
*/
228273
private function resolveModulePathCestNames($moduleName)
229274
{
230275
$cestObjects = [];
@@ -245,4 +290,4 @@ private function resolveModulePathCestNames($moduleName)
245290

246291
return $cestObjects;
247292
}
248-
}
293+
}

src/Magento/FunctionalTestingFramework/Suite/Objects/SuiteObject.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,20 @@ class SuiteObject
1919
*/
2020
private $name;
2121

22-
2322
/**
2423
* Array of Cests to include for the suite.
2524
*
2625
* @var array
2726
*/
2827
private $includeCests = [];
2928

30-
3129
/**
3230
* Array of Cests to exclude for the suite.
3331
*
3432
* @var array
3533
*/
3634
private $excludeCests = [];
3735

38-
3936
/**
4037
* SuiteObject constructor.
4138
* @param string $name
@@ -134,6 +131,8 @@ private function resolveTests($relevantTestNames, $tests)
134131

135132
/**
136133
* Getter for before hooks.
134+
*
135+
* @return void
137136
*/
138137
public function getBeforeHook()
139138
{
@@ -142,9 +141,11 @@ public function getBeforeHook()
142141

143142
/**
144143
* Getter for after hooks.
144+
*
145+
* @return void
145146
*/
146147
public function getAfterHook()
147148
{
148149
//TODO implement getter for after hooks
149150
}
150-
}
151+
}

src/Magento/FunctionalTestingFramework/Suite/Parsers/SuiteDataParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ public function readSuiteData()
3535
{
3636
return $this->suiteData->get();
3737
}
38-
}
38+
}

src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public static function getInstance()
5555
* yml configuration for group run.
5656
*
5757
* @param string $suiteName
58+
* @return void
5859
*/
5960
public function generateSuite($suiteName)
6061
{
@@ -71,6 +72,8 @@ public function generateSuite($suiteName)
7172

7273
/**
7374
* Method which will be needed for adding preconditions and creating a corresponding group file for codeception.
75+
*
76+
* @return void
7477
*/
7578
private function generateGroupFile()
7679
{
@@ -83,6 +86,7 @@ private function generateGroupFile()
8386
*
8487
* @param string $suiteName
8588
* @param string $suitePath
89+
* @return void
8690
*/
8791
private function appendGroupEntryToConfig($suiteName, $suitePath)
8892
{
@@ -116,10 +120,11 @@ private function appendGroupEntryToConfig($suiteName, $suitePath)
116120
*
117121
* @param string $path
118122
* @param array $cests
123+
* @return void
119124
*/
120125
private function generateRelevantGroupTests($path, $cests)
121126
{
122127
$testGenerator = TestGenerator::getInstance($path, $cests);
123128
$testGenerator->createAllCestFiles();
124129
}
125-
}
130+
}

src/Magento/FunctionalTestingFramework/Test/Objects/CestObject.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ public function getAnnotations()
7474
return $this->annotations;
7575
}
7676

77+
/**
78+
* Returns the value(s) of an annotation by a specific name such as group
79+
*
80+
* @param string $name
81+
* @return array
82+
*/
7783
public function getAnnotationByName($name)
7884
{
7985
if (array_key_exists($name, $this->annotations)) {

src/Magento/FunctionalTestingFramework/Test/Objects/TestObject.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ public function getAnnotations()
7878
return $this->annotations;
7979
}
8080

81+
/**
82+
* Method to return the value(s) of a corresponding annotation such as group.
83+
*
84+
* @param string $name
85+
* @return array
86+
*/
8187
public function getAnnotationByName($name)
8288
{
8389
if (array_key_exists($name, $this->annotations)) {

src/Magento/FunctionalTestingFramework/Util/Filesystem/DirSetupUtil.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class DirSetupUtil
1010
/**
1111
* Method used to clean export dir if needed and create new empty export dir.
1212
*
13+
* @param string $fullPath
1314
* @return void
1415
*/
1516
public static function createGroupDir($fullPath)
@@ -44,4 +45,4 @@ private static function rmdirRecursive($directory)
4445

4546
rmdir($directory);
4647
}
47-
}
48+
}

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class TestGenerator
2020
const REQUIRED_ENTITY_REFERENCE = 'createDataKey';
2121
const GENERATED_DIR = '_generated';
2222

23-
2423
/**
2524
* Path to the export dir.
2625
*
@@ -44,20 +43,26 @@ class TestGenerator
4443

4544
/**
4645
* TestGenerator constructor.
46+
*
4747
* @param string $exportDir
48+
* @param array $cests
4849
*/
4950
private function __construct($exportDir, $cests)
5051
{
5152
// private constructor for factory
5253
$this->exportDirName = $exportDir ?? self::GENERATED_DIR;
53-
$this->exportDirectory = rtrim(TESTS_MODULE_PATH . DIRECTORY_SEPARATOR .
54-
self::GENERATED_DIR . DIRECTORY_SEPARATOR . $exportDir, DIRECTORY_SEPARATOR);
54+
$this->exportDirectory = rtrim(
55+
TESTS_MODULE_PATH . DIRECTORY_SEPARATOR . self::GENERATED_DIR . DIRECTORY_SEPARATOR . $exportDir,
56+
DIRECTORY_SEPARATOR
57+
);
5558
$this->cests = $cests;
5659
}
5760

5861
/**
5962
* Singleton method to retrieve Test Generator
6063
*
64+
* @param string $dir
65+
* @param array $cests
6166
* @return TestGenerator
6267
*/
6368
public static function getInstance($dir = null, $cests = null)

0 commit comments

Comments
 (0)