Skip to content
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

feat(apitester): add filter on tags #65

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions src/Command/ExecutePlanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ protected function configure(): void
InputOption::VALUE_OPTIONAL,
'takes an operation-id to load from api definition'
)
->addOption(
'filter-tags',
null,
InputOption::VALUE_OPTIONAL,
'Filters which tests to run based on their openapi tags'
)
;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Definition/Loader/OpenApiDefinitionLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ private function getOperations(array $paths, array $securitySchemes, array $filt
&& !in_array($operation->operationId, $filters['operationId'], true)) {
continue;
}
if (isset($filters['tags'])
&& empty(array_intersect($operation->tags, $filters['tags']))) {
continue;
}
/** @var \cebe\openapi\spec\Parameter[] $parameters */
$parameters = array_merge($operation->parameters ?? [], $pathInfo->parameters ?? []);
/** @var RequestBody $requestBody */
Expand Down
7 changes: 7 additions & 0 deletions src/Test/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ final class Plan
'only-baseline',
'part',
'operation-id',
'filter-tags',
];

private readonly Authenticator $authenticator;
Expand Down Expand Up @@ -313,6 +314,12 @@ private function loadApiDefinition(Config\Suite $config, array $options = []): A
explode(',', (string) $options['operation-id'])
);
}
if (isset($options['filter-tags'])) {
$filters['tags'] = array_map(
'trim',
explode(',', (string) $options['filter-tags'])
);
}

return $definitionLoader->load(
$config->getDefinition()
Expand Down
Loading