Skip to content

Commit 4a6d39d

Browse files
committed
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
- Making requested review changes
1 parent 995aa18 commit 4a6d39d

File tree

6 files changed

+23
-48
lines changed

6 files changed

+23
-48
lines changed

dev/tests/_bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
defined('TESTS_BP') || define('TESTS_BP', __DIR__);
6161
defined('TESTS_MODULE_PATH') || define('TESTS_MODULE_PATH', TESTS_BP . $RELATIVE_TESTS_MODULE_PATH);
6262
defined('MAGENTO_BP') || define('MAGENTO_BP', __DIR__);
63-
define('OUTPUT_DIR',
63+
define('DOCS_OUTPUT_DIR',
6464
FW_BP .
6565
DIRECTORY_SEPARATOR .
6666
"dev" .

dev/tests/unit/Magento/FunctionalTestFramework/Util/DocGeneratorTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public function testBasicCreateDocumentation()
3232
->build();
3333
DocGenerator::getInstance()->createDocumentation(
3434
[$actionGroupUnderTest->getName() => $actionGroupUnderTest],
35-
OUTPUT_DIR,
35+
DOCS_OUTPUT_DIR,
3636
true
3737
);
3838

39-
$docFile = OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md";
39+
$docFile = DOCS_OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md";
4040

4141
$this->assertTrue(file_exists($docFile));
4242

@@ -63,7 +63,7 @@ public function testCreateDocumentationWithOverwrite()
6363
->build();
6464
DocGenerator::getInstance()->createDocumentation(
6565
[$actionGroupUnderTest->getName() => $actionGroupUnderTest],
66-
OUTPUT_DIR,
66+
DOCS_OUTPUT_DIR,
6767
true
6868
);
6969

@@ -77,11 +77,11 @@ public function testCreateDocumentationWithOverwrite()
7777
->build();
7878
DocGenerator::getInstance()->createDocumentation(
7979
[$actionGroupUnderTest->getName() => $actionGroupUnderTest],
80-
OUTPUT_DIR,
80+
DOCS_OUTPUT_DIR,
8181
true
8282
);
8383

84-
$docFile = OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md";
84+
$docFile = DOCS_OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md";
8585

8686
$this->assertTrue(file_exists($docFile));
8787

@@ -108,18 +108,18 @@ public function testCreateDocumentationNotCleanException()
108108
->build();
109109
DocGenerator::getInstance()->createDocumentation(
110110
[$actionGroupUnderTest->getName() => $actionGroupUnderTest],
111-
OUTPUT_DIR,
111+
DOCS_OUTPUT_DIR,
112112
true
113113
);
114114

115-
$docFile = OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md";
115+
$docFile = DOCS_OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md";
116116

117117
$this->expectException(TestFrameworkException::class);
118118
$this->expectExceptionMessage("$docFile already exists, please add --clean if you want to overwrite it.");
119119

120120
DocGenerator::getInstance()->createDocumentation(
121121
[$actionGroupUnderTest->getName() => $actionGroupUnderTest],
122-
OUTPUT_DIR,
122+
DOCS_OUTPUT_DIR,
123123
false
124124
);
125125
}

dev/tests/unit/Util/MagentoTestCase.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ class MagentoTestCase extends TestCase
1616
{
1717
public static function setUpBeforeClass()
1818
{
19-
if (!self::fileExists(OUTPUT_DIR)) {
20-
mkdir(OUTPUT_DIR, 0755, true);
19+
if (!self::fileExists(DOCS_OUTPUT_DIR)) {
20+
mkdir(DOCS_OUTPUT_DIR, 0755, true);
2121
}
2222
parent::setUpBeforeClass();
2323
}
@@ -29,9 +29,9 @@ public static function setUpBeforeClass()
2929
public static function tearDownAfterClass()
3030
{
3131
AspectMock::clean();
32-
array_map('unlink', glob(OUTPUT_DIR . DIRECTORY_SEPARATOR . "*"));
33-
if (file_exists(OUTPUT_DIR)) {
34-
rmdir(OUTPUT_DIR);
32+
array_map('unlink', glob(DOCS_OUTPUT_DIR . DIRECTORY_SEPARATOR . "*"));
33+
if (file_exists(DOCS_OUTPUT_DIR)) {
34+
rmdir(DOCS_OUTPUT_DIR);
3535
}
3636
}
3737
}

src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ protected function configure()
3737
'c',
3838
InputOption::VALUE_NONE,
3939
'Clean Output Directory'
40-
);
40+
)->addOption(
41+
"force",
42+
'f',
43+
InputOption::VALUE_NONE,
44+
'Force Document Generation For All Action Groups'
45+
);
4146
}
4247

4348
/**
@@ -55,17 +60,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
5560
defined('COMMAND') || define('COMMAND', 'generate:docs');
5661
$config = $input->getOption('output');
5762
$clean = $input->getOption('clean');
63+
$force = $input->getOption('force');
5864

5965
MftfApplicationConfig::create(
60-
true,
66+
$force,
6167
MftfApplicationConfig::GENERATION_PHASE,
6268
false,
6369
false
6470
);
6571

6672
$allActionGroups = ActionGroupObjectHandler::getInstance()->getAllObjects();
6773

68-
DocGenerator::getInstance()->createDocumentation($allActionGroups, $config, $clean);
74+
DocGenerator::createDocumentation($allActionGroups, $config, $clean);
6975

7076
$output->writeln("Generate Docs Command Run");
7177
}

src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupAnnotationExtractor.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public function extractAnnotations($testAnnotations, $filename)
3333
$annotationObjects = [];
3434
$annotations = $this->stripDescriptorTags($testAnnotations, parent::NODE_NAME);
3535

36-
// parse the Test annotations
37-
3836
foreach ($annotations as $annotationKey => $annotationData) {
3937
$annotationObjects[$annotationKey] = $annotationData[parent::ANNOTATION_VALUE];
4038
}

src/Magento/FunctionalTestingFramework/Util/DocGenerator.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,11 @@ class DocGenerator
2626
DIRECTORY_SEPARATOR .
2727
"docs";
2828
const DOC_NAME = "documentation.md";
29-
const ANNOTATION_MODULE = "";
3029
const ANNOTATION_PAGE = "page";
3130
const ANNOTATION_DESCRIPTION = "description";
3231
const FILENAMES = "filenames";
3332
const ARGUMENTS = "arguments";
3433

35-
/**
36-
* Single instance of class var
37-
*
38-
* @var ActionGroupObjectHandler
39-
*/
40-
private static $instance;
41-
42-
/**
43-
* Array of action groups
44-
*
45-
* @var ActionGroupObjectHandler
46-
*/
47-
private $actionGroups;
48-
49-
/**
50-
* Singleton getter for instance of ActionGroupObjectHandler
51-
*
52-
* @return ActionGroupObjectHandler
53-
*/
54-
public static function getInstance(): DocGenerator
55-
{
56-
if (!self::$instance) {
57-
self::$instance = new DocGenerator();
58-
}
59-
60-
return self::$instance;
61-
}
62-
6334
/**
6435
* DocGenerator constructor.
6536
*

0 commit comments

Comments
 (0)