Skip to content

chore: symfony dev tests #6805

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

Merged
merged 1 commit into from
Nov 18, 2024
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
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
Loading