File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1111
1212namespace Symfony \UX \LiveComponent \Util ;
1313
14+ use Symfony \Component \Routing \Exception \MethodNotAllowedException ;
1415use Symfony \Component \Routing \Exception \MissingMandatoryParametersException ;
1516use Symfony \Component \Routing \Exception \ResourceNotFoundException ;
1617use Symfony \Component \Routing \RouterInterface ;
@@ -43,7 +44,7 @@ public function createFromPreviousAndProps(
4344
4445 try {
4546 $ newUrl = $ this ->createPath ($ previousUrl , $ pathMappedProps );
46- } catch (ResourceNotFoundException |MissingMandatoryParametersException ) {
47+ } catch (ResourceNotFoundException |MethodNotAllowedException | MissingMandatoryParametersException ) {
4748 return null ;
4849 }
4950
Original file line number Diff line number Diff line change 1212namespace Symfony \UX \LiveComponent \Tests \Unit \Util ;
1313
1414use PHPUnit \Framework \TestCase ;
15+ use Symfony \Component \Routing \Exception \MethodNotAllowedException ;
1516use Symfony \Component \Routing \Exception \MissingMandatoryParametersException ;
1617use Symfony \Component \Routing \Exception \ResourceNotFoundException ;
1718use Symfony \Component \Routing \RouterInterface ;
@@ -140,6 +141,19 @@ public function testResourceNotFoundException()
140141 $ this ->assertNull ($ factory ->createFromPreviousAndProps ($ previousUrl , [], []));
141142 }
142143
144+ public function testMethodNotAllowedException ()
145+ {
146+ $ previousUrl = '/foo/bar ' ;
147+ $ router = $ this ->createMock (RouterInterface::class);
148+ $ router ->expects (self ::once ())
149+ ->method ('match ' )
150+ ->with ($ previousUrl )
151+ ->willThrowException (new MethodNotAllowedException (['GET ' ]));
152+ $ factory = new UrlFactory ($ router );
153+
154+ $ this ->assertNull ($ factory ->createFromPreviousAndProps ($ previousUrl , [], []));
155+ }
156+
143157 public function testMissingMandatoryParametersException ()
144158 {
145159 $ previousUrl = '/foo/bar ' ;
You can’t perform that action at this time.
0 commit comments