From f8e7caf162b6c592290940993a8118d7f9b1d362 Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Fri, 8 Nov 2024 09:33:31 +0100 Subject: [PATCH] Replaced all old constructor syntax calls for SimplifiedRequest --- tests/bundle/Core/Routing/DefaultRouterTest.php | 7 +------ .../SimplifiedRequestNormalizerTest.php | 3 +++ .../SiteAccessMatchListenerTest.php | 16 +++++++--------- .../SiteAccess/Compound/CompoundAndTest.php | 4 ++-- .../SiteAccess/Compound/CompoundOrTest.php | 4 ++-- .../Symfony/SiteAccess/RouterHostElementTest.php | 6 +++--- .../Symfony/SiteAccess/RouterHostPortURITest.php | 6 +++--- .../Symfony/SiteAccess/RouterHostTextTest.php | 2 +- .../MVC/Symfony/SiteAccess/RouterMapURITest.php | 8 ++++---- .../Symfony/SiteAccess/RouterURIElement2Test.php | 14 +++++++------- .../Symfony/SiteAccess/RouterURIElementTest.php | 10 +++++----- .../MVC/Symfony/SiteAccess/RouterURITextTest.php | 2 +- 12 files changed, 39 insertions(+), 43 deletions(-) diff --git a/tests/bundle/Core/Routing/DefaultRouterTest.php b/tests/bundle/Core/Routing/DefaultRouterTest.php index 71609b38cb..cd3a45a3a3 100644 --- a/tests/bundle/Core/Routing/DefaultRouterTest.php +++ b/tests/bundle/Core/Routing/DefaultRouterTest.php @@ -246,12 +246,7 @@ public function testGenerateReverseSiteAccessMatch() $siteAccessName = 'foo_test'; $siteAccessRouter = $this->createMock(SiteAccess\SiteAccessRouterInterface::class); $versatileMatcher = $this->createMock(SiteAccess\VersatileMatcher::class); - $simplifiedRequest = new SimplifiedRequest( - [ - 'host' => 'phoenix-rises.fm', - 'scheme' => 'http', - ] - ); + $simplifiedRequest = new SimplifiedRequest('http', 'phoenix-rises.fm'); $versatileMatcher ->expects(self::once()) ->method('getRequest') diff --git a/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php index 9cc32f0297..da30ae9699 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/SimplifiedRequestNormalizerTest.php @@ -14,6 +14,9 @@ final class SimplifiedRequestNormalizerTest extends TestCase { + /** + * @todo Remove together with old syntax for \Ibexa\Core\MVC\Symfony\Routing\SimplifiedRequest::__construct in 6.0.0 + */ public function testNormalize(): void { $request = new SimplifiedRequest([ diff --git a/tests/lib/MVC/Symfony/EventListener/SiteAccessMatchListenerTest.php b/tests/lib/MVC/Symfony/EventListener/SiteAccessMatchListenerTest.php index f9435bb42e..04e776f1cc 100644 --- a/tests/lib/MVC/Symfony/EventListener/SiteAccessMatchListenerTest.php +++ b/tests/lib/MVC/Symfony/EventListener/SiteAccessMatchListenerTest.php @@ -254,15 +254,13 @@ private function assertRequestHasSiteAccess( ); $simplifiedRequest = new SimplifiedRequest( - [ - 'scheme' => $originalRequest->getScheme(), - 'host' => $originalRequest->getHost(), - 'port' => $originalRequest->getPort(), - 'pathinfo' => $originalRequest->getPathInfo(), - 'queryParams' => $originalRequest->query->all(), - 'languages' => $originalRequest->getLanguages(), - 'headers' => $originalRequest->headers->all(), - ] + $originalRequest->getScheme(), + $originalRequest->getHost(), + $originalRequest->getPort(), + $originalRequest->getPathInfo(), + $originalRequest->query->all(), + $originalRequest->getLanguages(), + $originalRequest->headers->all(), ); $this->saRouter diff --git a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php index 32a33be0a3..8db7c5688b 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundAndTest.php @@ -320,11 +320,11 @@ public function testReverseMatch() public function testSerialize() { $matcher = new LogicalAnd([]); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar')); $sa = new SiteAccess('test', 'test', $matcher); $serializedSA1 = serialize($sa); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar/baz'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar/baz')); $serializedSA2 = serialize($sa); self::assertSame($serializedSA1, $serializedSA2); diff --git a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php index 5a5ced475e..dad491048d 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/Compound/CompoundOrTest.php @@ -322,11 +322,11 @@ public function testReverseMatch2() public function testSerialize() { $matcher = new LogicalOr([]); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar')); $sa = new SiteAccess('test', 'test', $matcher); $serializedSA1 = serialize($sa); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar/baz'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar/baz')); $serializedSA2 = serialize($sa); self::assertSame($serializedSA1, $serializedSA2); diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterHostElementTest.php b/tests/lib/MVC/Symfony/SiteAccess/RouterHostElementTest.php index 4b9ae194dc..8a7eb4a0af 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterHostElementTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterHostElementTest.php @@ -107,18 +107,18 @@ public function reverseMatchProvider() public function testReverseMatchFail() { $matcher = new HostElement([3]); - $matcher->setRequest(new SimplifiedRequest(['host' => 'ibexa.co'])); + $matcher->setRequest(new SimplifiedRequest('http', 'ibexa.co')); self::assertNull($matcher->reverseMatch('foo')); } public function testSerialize() { $matcher = new HostElement([1]); - $matcher->setRequest(new SimplifiedRequest(['host' => 'ibexa.co', 'pathinfo' => '/foo/bar'])); + $matcher->setRequest(new SimplifiedRequest('http', 'ibexa.co', 80, '/foo/bar')); $sa = new SiteAccess('test', 'test', $matcher); $serializedSA1 = serialize($sa); - $matcher->setRequest(new SimplifiedRequest(['host' => 'ibexa.co', 'pathinfo' => '/foo/bar/baz'])); + $matcher->setRequest(new SimplifiedRequest('http', 'ibexa.co', 80, '/foo/bar/baz')); $serializedSA2 = serialize($sa); self::assertSame($serializedSA1, $serializedSA2); diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php b/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php index 332bd6d14f..7e9d96c9c8 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterHostPortURITest.php @@ -86,7 +86,7 @@ public function matchProvider(): array public function testSetGetRequestMapHost() { $mapKey = 'phoenix-rises.fm'; - $request = new SimplifiedRequest(['host' => $mapKey]); + $request = new SimplifiedRequest('http', $mapKey); $matcher = new Host(['foo' => $mapKey]); $matcher->setRequest($request); self::assertSame($request, $matcher->getRequest()); @@ -107,7 +107,7 @@ public function testReverseMatchHost() 'something_else' => 'another_siteaccess', 'phoenix-rises.fm' => 'ibexa_demo_site', ]; - $request = new SimplifiedRequest(['host' => 'ibexa.co']); + $request = new SimplifiedRequest('http', 'ibexa.co'); $matcher = new Host($config); $matcher->setRequest($request); self::assertSame('ibexa.co', $matcher->getMapKey()); @@ -122,7 +122,7 @@ public function testReverseMatchHost() public function testSetGetRequestMapPort() { $mapKey = 8000; - $request = new SimplifiedRequest(['port' => $mapKey]); + $request = new SimplifiedRequest('http', '', $mapKey); $matcher = new Port(['foo' => $mapKey]); $matcher->setRequest($request); self::assertSame($request, $matcher->getRequest()); diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterHostTextTest.php b/tests/lib/MVC/Symfony/SiteAccess/RouterHostTextTest.php index 44aa82c7cf..c185d744ef 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterHostTextTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterHostTextTest.php @@ -86,7 +86,7 @@ public function testReverseMatch() ] ); - $matcher->setRequest(new SimplifiedRequest(['host' => 'www.my_siteaccess.com'])); + $matcher->setRequest(new SimplifiedRequest('http', 'www.my_siteaccess.com')); $result = $matcher->reverseMatch('foobar'); self::assertInstanceOf(HostTextMatcher::class, $result); diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterMapURITest.php b/tests/lib/MVC/Symfony/SiteAccess/RouterMapURITest.php index 255c16a321..a78712c5cc 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterMapURITest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterMapURITest.php @@ -22,7 +22,7 @@ class RouterMapURITest extends TestCase */ public function testSetGetRequest($config, $pathinfo, $expectedMapKey) { - $request = new SimplifiedRequest(['pathinfo' => $pathinfo]); + $request = new SimplifiedRequest('http', '', 80, $pathinfo); $matcher = new URIMapMatcher($config); $matcher->setRequest($request); self::assertSame($request, $matcher->getRequest()); @@ -39,7 +39,7 @@ public function testAnalyseURI($uri, $expectedFixedUpURI) { $matcher = new URIMapMatcher([]); $matcher->setRequest( - new SimplifiedRequest(['pathinfo' => $uri]) + new SimplifiedRequest('http', '', 80, $uri) ); self::assertSame($expectedFixedUpURI, $matcher->analyseURI($uri)); // Unserialized matcher should have the same behavior @@ -57,7 +57,7 @@ public function testAnalyseLink($fullUri, $linkUri) { $matcher = new URIMapMatcher([]); $matcher->setRequest( - new SimplifiedRequest(['pathinfo' => $fullUri]) + new SimplifiedRequest('http', '', 80, $fullUri) ); self::assertSame($fullUri, $matcher->analyseLink($linkUri)); // Unserialized matcher should have the same behavior @@ -100,7 +100,7 @@ public function testReverseMatch() 'something_else' => 'another_siteaccess', 'toutouyoutou' => 'ibexa_demo_site', ]; - $request = new SimplifiedRequest(['pathinfo' => '/foo']); + $request = new SimplifiedRequest('http', '', 80, '/foo'); $matcher = new URIMapMatcher($config); $matcher->setRequest($request); diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterURIElement2Test.php b/tests/lib/MVC/Symfony/SiteAccess/RouterURIElement2Test.php index 0403e78954..b5367500ba 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterURIElement2Test.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterURIElement2Test.php @@ -78,7 +78,7 @@ public function testAnalyseURI($level, $uri, $expectedFixedUpURI) { $matcher = new URIElementMatcher([$level]); $matcher->setRequest( - new SimplifiedRequest(['pathinfo' => $uri]) + new SimplifiedRequest('http', '', 80, $uri) ); self::assertSame($expectedFixedUpURI, $matcher->analyseURI($uri)); } @@ -94,7 +94,7 @@ public function testAnalyseURILevelAsInt($level, $uri, $expectedFixedUpURI) { $matcher = new URIElementMatcher($level); $matcher->setRequest( - new SimplifiedRequest(['pathinfo' => $uri]) + new SimplifiedRequest('http', '', 80, $uri) ); self::assertSame($expectedFixedUpURI, $matcher->analyseURI($uri)); } @@ -110,7 +110,7 @@ public function testAnalyseLink($level, $fullUri, $linkUri) { $matcher = new URIElementMatcher([$level]); $matcher->setRequest( - new SimplifiedRequest(['pathinfo' => $fullUri]) + new SimplifiedRequest('http', '', 80, $fullUri) ); self::assertSame($fullUri, $matcher->analyseLink($linkUri)); } @@ -140,7 +140,7 @@ public function testReverseMatch($siteAccessName, $originalPathinfo) { $expectedSiteAccessPath = str_replace('_', '/', $siteAccessName); $matcher = new URIElementMatcher([2]); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => $originalPathinfo])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, $originalPathinfo)); $result = $matcher->reverseMatch($siteAccessName); self::assertInstanceOf(URIElement::class, $result); @@ -160,18 +160,18 @@ public function reverseMatchProvider() public function testReverseMatchFail() { $matcher = new URIElementMatcher([2]); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/my/siteaccess/foo/bar'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/my/siteaccess/foo/bar')); self::assertNull($matcher->reverseMatch('another_siteaccess_again_dont_tell_me')); } public function testSerialize() { $matcher = new URIElementMatcher([2]); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar')); $sa = new SiteAccess('test', 'test', $matcher); $serializedSA1 = serialize($sa); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar/baz'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar/baz')); $serializedSA2 = serialize($sa); self::assertSame($serializedSA1, $serializedSA2); diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterURIElementTest.php b/tests/lib/MVC/Symfony/SiteAccess/RouterURIElementTest.php index d5a73c8d65..070ac79390 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterURIElementTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterURIElementTest.php @@ -83,7 +83,7 @@ public function testAnalyseURI($uri, $expectedFixedUpURI) { $matcher = new URIElementMatcher([1]); $matcher->setRequest( - new SimplifiedRequest(['pathinfo' => $uri]) + new SimplifiedRequest('http', '', 80, $uri) ); self::assertSame($expectedFixedUpURI, $matcher->analyseURI($uri)); } @@ -98,7 +98,7 @@ public function testAnalyseLink($fullUri, $linkUri) { $matcher = new URIElementMatcher([1]); $matcher->setRequest( - new SimplifiedRequest(['pathinfo' => $fullUri]) + new SimplifiedRequest('http', '', 80, $fullUri) ); self::assertSame($fullUri, $matcher->analyseLink($linkUri)); } @@ -117,7 +117,7 @@ public function analyseProvider() public function testReverseMatch($siteAccessName, $originalPathinfo) { $matcher = new URIElementMatcher([1]); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => $originalPathinfo])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, $originalPathinfo)); $result = $matcher->reverseMatch($siteAccessName); self::assertInstanceOf(URIElement::class, $result); self::assertSame("/{$siteAccessName}{$originalPathinfo}", $result->getRequest()->getPathInfo()); @@ -139,11 +139,11 @@ public function reverseMatchProvider() public function testSerialize() { $matcher = new URIElementMatcher([1]); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar')); $sa = new SiteAccess('test', 'test', $matcher); $serializedSA1 = serialize($sa); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => '/foo/bar/baz'])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, '/foo/bar/baz')); $serializedSA2 = serialize($sa); self::assertSame($serializedSA1, $serializedSA2); diff --git a/tests/lib/MVC/Symfony/SiteAccess/RouterURITextTest.php b/tests/lib/MVC/Symfony/SiteAccess/RouterURITextTest.php index f07eb0ff10..b38690137c 100644 --- a/tests/lib/MVC/Symfony/SiteAccess/RouterURITextTest.php +++ b/tests/lib/MVC/Symfony/SiteAccess/RouterURITextTest.php @@ -118,7 +118,7 @@ public function testReverseMatch() 'suffix' => 'bar', ] ); - $matcher->setRequest(new SimplifiedRequest(['pathinfo' => $semanticURI])); + $matcher->setRequest(new SimplifiedRequest('http', '', 80, 'pathinfo')); $result = $matcher->reverseMatch('something'); self::assertInstanceOf(URIText::class, $result);