Renamed ShortUrlInputFilter and added named constructors to it

This commit is contained in:
Alejandro Celaya
2021-01-31 07:44:46 +01:00
parent 08f4a424e6
commit 7e90fd45a7
13 changed files with 99 additions and 92 deletions

View File

@@ -13,7 +13,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Shlinkio\Shlink\Core\Validation\ShortUrlMetaInputFilter;
use Shlinkio\Shlink\Core\Validation\ShortUrlInputFilter;
use Shlinkio\Shlink\Rest\Middleware\ShortUrl\DefaultShortCodesLengthMiddleware;
class DefaultShortCodesLengthMiddlewareTest extends TestCase
@@ -38,8 +38,8 @@ class DefaultShortCodesLengthMiddlewareTest extends TestCase
$request = ServerRequestFactory::fromGlobals()->withParsedBody($body);
$handle = $this->handler->handle(Argument::that(function (ServerRequestInterface $req) use ($expectedLength) {
$parsedBody = $req->getParsedBody();
Assert::assertArrayHasKey(ShortUrlMetaInputFilter::SHORT_CODE_LENGTH, $parsedBody);
Assert::assertEquals($expectedLength, $parsedBody[ShortUrlMetaInputFilter::SHORT_CODE_LENGTH]);
Assert::assertArrayHasKey(ShortUrlInputFilter::SHORT_CODE_LENGTH, $parsedBody);
Assert::assertEquals($expectedLength, $parsedBody[ShortUrlInputFilter::SHORT_CODE_LENGTH]);
return $req;
}))->willReturn(new Response());
@@ -51,7 +51,7 @@ class DefaultShortCodesLengthMiddlewareTest extends TestCase
public function provideBodies(): iterable
{
yield 'value provided' => [[ShortUrlMetaInputFilter::SHORT_CODE_LENGTH => 6], 6];
yield 'value provided' => [[ShortUrlInputFilter::SHORT_CODE_LENGTH => 6], 6];
yield 'value not provided' => [[], 8];
}
}