Skip to content

Commit

Permalink
chore: symfony dev tests (#6805)
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka authored Nov 18, 2024
1 parent f251ed1 commit d64ba84
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
9 changes: 1 addition & 8 deletions src/Symfony/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
namespace ApiPlatform\Symfony\Routing;

use ApiPlatform\Metadata\UrlGeneratorInterface;
use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -75,12 +73,7 @@ public function match(string $pathInfo): array
}

$request = Request::create($pathInfo, Request::METHOD_GET, [], [], [], ['HTTP_HOST' => $baseContext->getHost()]);
try {
$context = (new RequestContext())->fromRequest($request);
} catch (RequestExceptionInterface) {
throw new ResourceNotFoundException('Invalid request context.');
}

$context = (new RequestContext())->fromRequest($request);
$context->setPathInfo($pathInfo);
$context->setScheme($baseContext->getScheme());
$context->setHost($baseContext->getHost());
Expand Down
1 change: 1 addition & 0 deletions tests/.ignored-deprecations
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
%Since api-platform/core 3.4: Injecting the "ApiPlatform\\JsonSchema\\TypeFactoryInterface" inside "ApiPlatform\\JsonSchema\\SchemaFactory" is deprecated and "ApiPlatform\\JsonSchema\\TypeFactoryInterface" will be removed in 4.x.%
%Since api-platform/core 3.4: Injecting the "ApiPlatform\\JsonSchema\\TypeFactoryInterface" inside "ApiPlatform\\OpenApi\\Factory\\OpenApiFactory" is deprecated and "ApiPlatform\\JsonSchema\\TypeFactoryInterface" will be removed in 4.x.%
%Since api-platform/core 3.3: Use a "ApiPlatform\\State\\ProviderInterface" as first argument in "ApiPlatform\\Symfony\\EventListener\\QueryParameterValidateListener" instead of "ApiPlatform\\ParameterValidator\\ParameterValidator".%
%Use quoteSingleIdentifier\(\) individually for each part of a qualified name instead.%
14 changes: 0 additions & 14 deletions tests/Symfony/Routing/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\Routing\Exception\ExceptionInterface as RoutingExceptionInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -96,19 +95,6 @@ public function testMatch(): void
$this->assertEquals(['bar'], $router->match('/app_dev.php/foo'));
}

public function testMatchWithInvalidContext(): void
{
$this->expectException(RoutingExceptionInterface::class);
$this->expectExceptionMessage('Invalid request context.');
$context = new RequestContext('/app_dev.php', 'GET', 'localhost', 'https');

$mockedRouter = $this->prophesize(RouterInterface::class);
$mockedRouter->getContext()->willReturn($context)->shouldBeCalled();

$router = new Router($mockedRouter->reveal());
$router->match('28-01-2018 10:10');
}

public function testMatchDuplicatedBaseUrl(): void
{
$context = new RequestContext('/app', 'GET', 'localhost', 'https');
Expand Down

0 comments on commit d64ba84

Please sign in to comment.