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
3 changes: 2 additions & 1 deletion src/LiveComponent/src/Util/UrlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\UX\LiveComponent\Util;

use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -43,7 +44,7 @@ public function createFromPreviousAndProps(

try {
$newUrl = $this->createPath($previousUrl, $pathMappedProps);
} catch (ResourceNotFoundException|MissingMandatoryParametersException) {
} catch (ResourceNotFoundException|MethodNotAllowedException|MissingMandatoryParametersException) {
return null;
}

Expand Down
14 changes: 14 additions & 0 deletions src/LiveComponent/tests/Unit/Util/UrlFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\UX\LiveComponent\Tests\Unit\Util;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -140,6 +141,19 @@ public function testResourceNotFoundException()
$this->assertNull($factory->createFromPreviousAndProps($previousUrl, [], []));
}

public function testMethodNotAllowedException()
{
$previousUrl = '/foo/bar';
$router = $this->createMock(RouterInterface::class);
$router->expects(self::once())
->method('match')
->with($previousUrl)
->willThrowException(new MethodNotAllowedException(['GET']));
$factory = new UrlFactory($router);

$this->assertNull($factory->createFromPreviousAndProps($previousUrl, [], []));
}

public function testMissingMandatoryParametersException()
{
$previousUrl = '/foo/bar';
Expand Down
Loading