Skip to content

MQE-2018: Remove dead code: GenerateDocsCommand #636

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 2 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,6 @@ public function testActionGroupExtractAnnotations()
$this->assertEquals("someDescription", $returnedAnnotations['description']);
}

/**
* Annotation extractor should throw warning when required annotations are missing
*
* @throws \Exception
*/
public function testActionGroupMissingAnnotations()
{
// Action Group Data, missing 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"
]
);
}

/**
* 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 description
$testAnnotations = [];
// Perform Test
$extractor = new ActionGroupAnnotationExtractor();
$extractor->extractAnnotations($testAnnotations, "fileName");

// Asserts
TestLoggingUtil::getInstance()->validateMockLogEmpty();
}

/**
* After class functionality
* @return void
Expand Down

This file was deleted.

34 changes: 0 additions & 34 deletions docs/commands/mftf.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,6 @@ vendor/bin/mftf run:failed
This command cleans up the previously generated tests; generates and runs the tests listed in `dev/tests/acceptance/tests/_output/failed`.
For more details about `failed`, refer to [Reporting][].

### Generate documentation for action groups

```bash
vendor/bin/mftf generate:docs
```

This command generates documentation for action groups.

## Reference

### `build:project`
Expand Down Expand Up @@ -270,32 +262,6 @@ vendor/bin/mftf generate:urn-catalog [--force] [<path to the directory with misc
vendor/bin/mftf generate:urn-catalog .idea/
```

### `generate:docs`

#### Description

Generates documentation that lists all action groups available in the codebase.
The default path is `<projectRoot>/dev/tests/docs/documentation.md`.

#### Usage

```bash
vendor/bin/mftf generate:docs [--clean] [--output=/path/to/alternate/dir]
```

#### Options

| Option | Description |
| ------------- | --------------------------------------------------------------------- |
| `-c, --clean` | Overwrites previously existing documentation |
| `-o, --output` | Changes the default output directory to a user specified directory |

#### Example

```bash
vendor/bin/mftf generate:docs --clean
```

### `reset`

#### Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function __construct(array $commands = [])
$this->commands = [
'build:project' => new BuildProjectCommand(),
'doctor' => new DoctorCommand(),
'generate:docs' => new GenerateDocsCommand(),
'generate:suite' => new GenerateSuiteCommand(),
'generate:tests' => new GenerateTestsCommand(),
'generate:urn-catalog' => new GenerateDevUrnCommand(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
*/
class ActionGroupAnnotationExtractor extends AnnotationExtractor
{
const ACTION_GROUP_REQUIRED_ANNOTATIONS = [
"description"
];
const GENERATE_DOCS_COMMAND = 'generate:docs';

/**
* This method trims away irrelevant tags and returns annotations used in the array passed. The annotations
* can be found in both Tests and their child element tests.
Expand All @@ -35,52 +30,7 @@ public function extractAnnotations($testAnnotations, $filename)
foreach ($annotations as $annotationKey => $annotationData) {
$annotationObjects[$annotationKey] = $annotationData[parent::ANNOTATION_VALUE];
}
// TODO: Remove this when all action groups have annotations
if ($this->isCommandDefined()) {
$this->validateMissingAnnotations($annotationObjects, $filename);
}

return $annotationObjects;
}

/**
* Validates given annotations against list of required annotations.
*
* @param array $annotationObjects
* @return void
* @throws \Exception
*/
private function validateMissingAnnotations($annotationObjects, $filename)
{
$missingAnnotations = [];

foreach (self::ACTION_GROUP_REQUIRED_ANNOTATIONS as $REQUIRED_ANNOTATION) {
if (!array_key_exists($REQUIRED_ANNOTATION, $annotationObjects)) {
$missingAnnotations[] = $REQUIRED_ANNOTATION;
}
}

if (!empty($missingAnnotations)) {
$message = "Action Group File {$filename} is missing required annotations.";
LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation(
$message,
["actionGroup" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)],
true
);
}
}

/**
* Checks if command is defined as generate:docs
*
* @return boolean
*/
private function isCommandDefined()
{
if (defined('COMMAND') and COMMAND == self::GENERATE_DOCS_COMMAND) {
return true;
} else {
return false;
}
}
}
Loading