Skip to content
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
8 changes: 5 additions & 3 deletions src/Config/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ private function handleTags(string|int|TaggedValue $value): array
$operator = '=';

if ($value instanceof TaggedValue) {
if ($value->getTag() === 'NOT') {
$operator = '!=';
}
match ($value->getTag()) {
'NOT' => $operator = '!=',
'IN' => $operator = 'contains',
default => $operator,
};
$value = (string) $value->getValue();
}

Expand Down
9 changes: 0 additions & 9 deletions src/Preparator/Config/Error400BadFormatsPreparatorConfig.php

This file was deleted.

9 changes: 0 additions & 9 deletions src/Preparator/Config/Error400BadTypesPreparatorConfig.php

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/Preparator/Config/Error400PreparatorConfig.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/Preparator/Error400Preparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
use APITester\Definition\Example\ResponseExample;
use APITester\Definition\Operation;
use APITester\Definition\Parameter;
use APITester\Preparator\Config\Error400PreparatorConfig;
use APITester\Test\TestCase;

/**
* @property Error400PreparatorConfig $config
*/
abstract class Error400Preparator extends TestCasesPreparator
{
/**
Expand Down Expand Up @@ -122,10 +118,6 @@ protected function getStatusCode(): string
*/
private function prepareTestCases(Operation $operation): array
{
if ($this->config->excludeOpenApiEndpoints
&& isset($operation->getExtensions()['x-usecase'])) {
return [];
}
$requiredParams = $operation->getParameters(true);

return array_merge(
Expand Down
1 change: 1 addition & 0 deletions src/Util/Traits/FilterableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ trait FilterableTrait
public function has(string $prop, $value, string $operator = '='): bool
{
$self = collect([$this]);

if (str_contains($prop, '*')) {
$operator = 'contains';
}
Expand Down
45 changes: 1 addition & 44 deletions tests/Preparator/Error400MissingRequiredFieldsPreparatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class Error400MissingRequiredFieldsPreparatorTest extends \PHPUnit\Framewo
* @dataProvider getData
*
* @param array<string, array<mixed>> $config
* @param TestCase[] $expected
* @param TestCase[] $expected
*/
public function test(Api $api, array $expected, array $config = []): void
{
Expand Down Expand Up @@ -165,48 +165,5 @@ public function getData(): iterable
),
],
];

yield 'openapi endpoint is ignored' => [
Api::create()
->addOperation(
Operation::create(
'test',
'/test',
'POST'
)
->addRequestBody(
(new Body(
new Schema([
'type' => 'object',
'properties' => [
'foo' => [
'type' => 'string',
],
'bar' => [
'type' => 'string',
],
],
'required' => ['foo'],
]),
'application/json'
))
)
->addExample(
OperationExample::create('foo')
->setBodyContent([
'foo' => 'foo_body1',
'bar' => 'bar_body1',
])
->setQueryParameter('foo_query', 'foo1')
)->setExtensions([
'x-usecase' => 'UseCaseName',
])
),
[
],
[
'excludeOpenApiEndpoints' => true,
],
];
}
}
Loading