mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 07:03:44 -06:00
Enhanced test covering list short URLs with invalid params
This commit is contained in:
parent
2abcaf02e2
commit
ff75b3cd1f
@ -42,6 +42,9 @@ class ValidationException extends InvalidArgumentException implements ProblemDet
|
||||
$e->invalidElements = $invalidData;
|
||||
$e->additional = ['invalidElements' => array_keys($invalidData)];
|
||||
|
||||
// TODO Expose reasons for the validation to fail
|
||||
// $e->additional = ['invalidElements' => array_keys($invalidData), 'reasons' => $invalidData];
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
|
@ -242,20 +242,29 @@ class ListShortUrlsTest extends ApiTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function errorIsReturnedWhenProvidingInvalidValues(): void
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideInvalidFiltering
|
||||
*/
|
||||
public function errorIsReturnedWhenProvidingInvalidValues(array $query, array $expectedInvalidElements): void
|
||||
{
|
||||
$query = ['tagsMode' => 'invalid'];
|
||||
$resp = $this->callApiWithKey(self::METHOD_GET, '/short-urls', [RequestOptions::QUERY => $query]);
|
||||
$respPayload = $this->getJsonResponsePayload($resp);
|
||||
|
||||
self::assertEquals(400, $resp->getStatusCode());
|
||||
self::assertEquals([
|
||||
'invalidElements' => ['tagsMode'],
|
||||
'invalidElements' => $expectedInvalidElements,
|
||||
'title' => 'Invalid data',
|
||||
'type' => 'INVALID_ARGUMENT',
|
||||
'status' => 400,
|
||||
'detail' => 'Provided data is not valid',
|
||||
], $respPayload);
|
||||
}
|
||||
|
||||
public function provideInvalidFiltering(): iterable
|
||||
{
|
||||
yield [['tagsMode' => 'invalid'], ['tagsMode']];
|
||||
yield [['orderBy' => 'invalid'], ['orderBy']];
|
||||
yield [['orderBy' => 'invalid', 'tagsMode' => 'invalid'], ['tagsMode', 'orderBy']];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user