-
Notifications
You must be signed in to change notification settings - Fork 132
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
00caa60
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra e0713ef
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra a22bd04
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra 995aa18
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra 4a6d39d
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra 6235795
MQE-1367: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra 8691c9b
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra b5f6488
MQE-1376: [SPIKE] Investigate Self-Documentation for MFTF
aljcalandra df4ad99
Merge branch 'develop' into MQE-1376
KevinBKozan 5f0bdd3
Merge branch 'develop' into MQE-1376
KevinBKozan 2f706cc
Merge branch 'develop' into MQE-1376
KevinBKozan 26fa3ce
Merge branch 'develop' into MQE-1376
KevinBKozan a766d44
Merge branch 'develop' into MQE-1376
KevinBKozan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...sts/unit/Magento/FunctionalTestFramework/Test/Util/ActionGroupAnnotationExtractorTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util; | ||
|
||
use AspectMock\Test as AspectMock; | ||
use Magento\FunctionalTestingFramework\Test\Util\ActionGroupAnnotationExtractor; | ||
use PHPUnit\Framework\TestCase; | ||
use tests\unit\Util\TestLoggingUtil; | ||
|
||
class ActionGroupAnnotationExtractorTest extends TestCase | ||
{ | ||
/** | ||
* Before test functionality | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
TestLoggingUtil::getInstance()->setMockLoggingUtil(); | ||
} | ||
|
||
/** | ||
* Annotation extractor takes in raw array and condenses it to expected format | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testActionGroupExtractAnnotations() | ||
{ | ||
// Test Data | ||
$actionGroupAnnotations = [ | ||
"nodeName" => "annotations", | ||
"description" => [ | ||
"nodeName" => "description", | ||
"value" => "someDescription" | ||
], | ||
"page" => [ | ||
"nodeName" => "page", | ||
"value" => "somePage" | ||
] | ||
]; | ||
// Perform Test | ||
$extractor = new ActionGroupAnnotationExtractor(); | ||
$returnedAnnotations = $extractor->extractAnnotations($actionGroupAnnotations, "fileName"); | ||
|
||
// Asserts | ||
|
||
$this->assertEquals("somePage", $returnedAnnotations['page']); | ||
$this->assertEquals("someDescription", $returnedAnnotations['description']); | ||
} | ||
|
||
/** | ||
* Annotation extractor should throw warning when required annotations are missing | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testActionGroupMissingAnnotations() | ||
{ | ||
// Action Group Data, missing page and description | ||
$testAnnotations = []; | ||
// Perform Test | ||
$extractor = new ActionGroupAnnotationExtractor(); | ||
AspectMock::double($extractor, ['isCommandDefined' => true]); | ||
$extractor->extractAnnotations($testAnnotations, "fileName"); | ||
|
||
// Asserts | ||
TestLoggingUtil::getInstance()->validateMockLogStatement( | ||
'warning', | ||
'DEPRECATION: Action Group File fileName is missing required annotations.', | ||
[ | ||
'actionGroup' => 'fileName', | ||
'missingAnnotations' => "description, page" | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Annotation extractor should not throw warning when required | ||
* annotations are missing if command is not generate:docs | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testActionGroupMissingAnnotationsNoWarning() | ||
{ | ||
// Action Group Data, missing page and description | ||
$testAnnotations = []; | ||
// Perform Test | ||
$extractor = new ActionGroupAnnotationExtractor(); | ||
$extractor->extractAnnotations($testAnnotations, "fileName"); | ||
|
||
// Asserts | ||
TestLoggingUtil::getInstance()->validateMockLogEmpty(); | ||
} | ||
|
||
/** | ||
* After class functionality | ||
* @return void | ||
*/ | ||
public static function tearDownAfterClass() | ||
{ | ||
TestLoggingUtil::getInstance()->clearMockLoggingUtil(); | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
dev/tests/unit/Magento/FunctionalTestFramework/Util/DocGeneratorTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Tests\unit\Magento\FunctionalTestFramework\Test\Handlers; | ||
|
||
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; | ||
use Magento\FunctionalTestingFramework\Util\MagentoTestCase; | ||
use Magento\FunctionalTestingFramework\Util\DocGenerator; | ||
use tests\unit\Util\ActionGroupObjectBuilder; | ||
|
||
class DocGeneratorTest extends MagentoTestCase | ||
{ | ||
const DOC_FILENAME = "documentation"; | ||
|
||
/** | ||
* Basic test to check creation of documentation | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testBasicCreateDocumentation() | ||
{ | ||
$annotations = [ | ||
"page" => "somePage", | ||
"description" => "someDescription" | ||
]; | ||
$actionGroupUnderTest = (new ActionGroupObjectBuilder()) | ||
->withAnnotations($annotations) | ||
->withFilenames(["filename"]) | ||
->build(); | ||
DocGenerator::getInstance()->createDocumentation( | ||
[$actionGroupUnderTest->getName() => $actionGroupUnderTest], | ||
OUTPUT_DIR, | ||
true | ||
); | ||
|
||
$docFile = OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md"; | ||
|
||
$this->assertTrue(file_exists($docFile)); | ||
|
||
$this->assertFileEquals( | ||
RESOURCE_DIR . DIRECTORY_SEPARATOR . "basicDocumentation.txt", | ||
$docFile | ||
); | ||
} | ||
|
||
/** | ||
* Test to check creation of documentation when overwriting previous | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testCreateDocumentationWithOverwrite() | ||
{ | ||
$annotations = [ | ||
"page" => "somePage", | ||
"description" => "someDescription" | ||
]; | ||
$actionGroupUnderTest = (new ActionGroupObjectBuilder()) | ||
->withAnnotations($annotations) | ||
->withFilenames(["filename"]) | ||
->build(); | ||
DocGenerator::getInstance()->createDocumentation( | ||
[$actionGroupUnderTest->getName() => $actionGroupUnderTest], | ||
OUTPUT_DIR, | ||
true | ||
); | ||
|
||
$annotations = [ | ||
"page" => "alteredPage", | ||
"description" => "alteredDescription" | ||
]; | ||
$actionGroupUnderTest = (new ActionGroupObjectBuilder()) | ||
->withAnnotations($annotations) | ||
->withFilenames(["filename"]) | ||
->build(); | ||
DocGenerator::getInstance()->createDocumentation( | ||
[$actionGroupUnderTest->getName() => $actionGroupUnderTest], | ||
OUTPUT_DIR, | ||
true | ||
); | ||
|
||
$docFile = OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md"; | ||
|
||
$this->assertTrue(file_exists($docFile)); | ||
|
||
$this->assertFileEquals( | ||
RESOURCE_DIR . DIRECTORY_SEPARATOR . "alteredDocumentation.txt", | ||
$docFile | ||
); | ||
} | ||
|
||
/** | ||
* Test for existing documentation without clean | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function testCreateDocumentationNotCleanException() | ||
{ | ||
$annotations = [ | ||
"page" => "somePage", | ||
"description" => "someDescription" | ||
]; | ||
$actionGroupUnderTest = (new ActionGroupObjectBuilder()) | ||
->withAnnotations($annotations) | ||
->withFilenames(["filename"]) | ||
->build(); | ||
DocGenerator::getInstance()->createDocumentation( | ||
[$actionGroupUnderTest->getName() => $actionGroupUnderTest], | ||
OUTPUT_DIR, | ||
true | ||
); | ||
|
||
$docFile = OUTPUT_DIR . DIRECTORY_SEPARATOR . self::DOC_FILENAME . ".md"; | ||
|
||
$this->expectException(TestFrameworkException::class); | ||
$this->expectExceptionMessage("$docFile already exists, please add --clean if you want to overwrite it."); | ||
|
||
DocGenerator::getInstance()->createDocumentation( | ||
[$actionGroupUnderTest->getName() => $actionGroupUnderTest], | ||
OUTPUT_DIR, | ||
false | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#Action Group Information | ||
This documentation contains a list of all action groups on the pages on which they start | ||
|
||
##List of Pages | ||
- [ alteredPage ](#alteredPage) | ||
--- | ||
<a name="alteredPage"></a> | ||
##alteredPage | ||
|
||
###testActionGroupObject | ||
alteredDescription | ||
|
||
Located in: | ||
|
||
*** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#Action Group Information | ||
This documentation contains a list of all action groups on the pages on which they start | ||
|
||
##List of Pages | ||
- [ somePage ](#somePage) | ||
--- | ||
<a name="somePage"></a> | ||
##somePage | ||
|
||
###testActionGroupObject | ||
someDescription | ||
|
||
Located in: | ||
|
||
*** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.