@@ -23,9 +23,9 @@ public function testCanMatchUrl(): void
2323 Router::addRoute ($ routeAbout );
2424 Router::addRoute ($ routeAboutMe );
2525
26- $ this ->assertEquals ($ routeIndex , Router::match (Http::REQUEST_METHOD_GET , '/ ' ));
27- $ this ->assertEquals ($ routeAbout , Router::match (Http::REQUEST_METHOD_GET , '/about ' ));
28- $ this ->assertEquals ($ routeAboutMe , Router::match (Http::REQUEST_METHOD_GET , '/about/me ' ));
26+ $ this ->assertSame ($ routeIndex , Router::match (Http::REQUEST_METHOD_GET , '/ ' )[ 0 ] ?? null );
27+ $ this ->assertSame ($ routeAbout , Router::match (Http::REQUEST_METHOD_GET , '/about ' )[ 0 ] ?? null );
28+ $ this ->assertSame ($ routeAboutMe , Router::match (Http::REQUEST_METHOD_GET , '/about/me ' )[ 0 ] ?? null );
2929 }
3030
3131 public function testCanMatchUrlWithPlaceholder (): void
@@ -44,12 +44,12 @@ public function testCanMatchUrlWithPlaceholder(): void
4444 Router::addRoute ($ routeBlogPostComments );
4545 Router::addRoute ($ routeBlogPostCommentsSingle );
4646
47- $ this ->assertEquals ($ routeBlog , Router::match (Http::REQUEST_METHOD_GET , '/blog ' ));
48- $ this ->assertEquals ($ routeBlogAuthors , Router::match (Http::REQUEST_METHOD_GET , '/blog/authors ' ));
49- $ this ->assertEquals ($ routeBlogAuthorsComments , Router::match (Http::REQUEST_METHOD_GET , '/blog/authors/comments ' ));
50- $ this ->assertEquals ($ routeBlogPost , Router::match (Http::REQUEST_METHOD_GET , '/blog/test ' ));
51- $ this ->assertEquals ($ routeBlogPostComments , Router::match (Http::REQUEST_METHOD_GET , '/blog/test/comments ' ));
52- $ this ->assertEquals ($ routeBlogPostCommentsSingle , Router::match (Http::REQUEST_METHOD_GET , '/blog/test/comments/:comment ' ));
47+ $ this ->assertSame ($ routeBlog , Router::match (Http::REQUEST_METHOD_GET , '/blog ' )[ 0 ] ?? null );
48+ $ this ->assertSame ($ routeBlogAuthors , Router::match (Http::REQUEST_METHOD_GET , '/blog/authors ' )[ 0 ] ?? null );
49+ $ this ->assertSame ($ routeBlogAuthorsComments , Router::match (Http::REQUEST_METHOD_GET , '/blog/authors/comments ' )[ 0 ] ?? null );
50+ $ this ->assertSame ($ routeBlogPost , Router::match (Http::REQUEST_METHOD_GET , '/blog/test ' )[ 0 ] ?? null );
51+ $ this ->assertSame ($ routeBlogPostComments , Router::match (Http::REQUEST_METHOD_GET , '/blog/test/comments ' )[ 0 ] ?? null );
52+ $ this ->assertSame ($ routeBlogPostCommentsSingle , Router::match (Http::REQUEST_METHOD_GET , '/blog/test/comments/:comment ' )[ 0 ] ?? null );
5353 }
5454
5555 public function testCanMatchUrlWithWildcard (): void
@@ -62,11 +62,11 @@ public function testCanMatchUrlWithWildcard(): void
6262 Router::addRoute ($ routeAbout );
6363 Router::addRoute ($ routeAboutWildcard );
6464
65- $ this ->assertEquals ($ routeIndex , Router::match ('GET ' , '/ ' ));
66- $ this ->assertEquals ($ routeAbout , Router::match ('GET ' , '/about ' ));
67- $ this ->assertEquals ($ routeAboutWildcard , Router::match ('GET ' , '/about/me ' ));
68- $ this ->assertEquals ($ routeAboutWildcard , Router::match ('GET ' , '/about/you ' ));
69- $ this ->assertEquals ($ routeAboutWildcard , Router::match ('GET ' , '/about/me/myself/i ' ));
65+ $ this ->assertSame ($ routeIndex , Router::match ('GET ' , '/ ' )[ 0 ] ?? null );
66+ $ this ->assertSame ($ routeAbout , Router::match ('GET ' , '/about ' )[ 0 ] ?? null );
67+ $ this ->assertSame ($ routeAboutWildcard , Router::match ('GET ' , '/about/me ' )[ 0 ] ?? null );
68+ $ this ->assertSame ($ routeAboutWildcard , Router::match ('GET ' , '/about/you ' )[ 0 ] ?? null );
69+ $ this ->assertSame ($ routeAboutWildcard , Router::match ('GET ' , '/about/me/myself/i ' )[ 0 ] ?? null );
7070 }
7171
7272 public function testCanMatchHttpMethod (): void
@@ -77,11 +77,11 @@ public function testCanMatchHttpMethod(): void
7777 Router::addRoute ($ routeGET );
7878 Router::addRoute ($ routePOST );
7979
80- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/ ' ));
81- $ this ->assertEquals ($ routePOST , Router::match (Http::REQUEST_METHOD_POST , '/ ' ));
80+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/ ' )[ 0 ] ?? null );
81+ $ this ->assertSame ($ routePOST , Router::match (Http::REQUEST_METHOD_POST , '/ ' )[ 0 ] ?? null );
8282
83- $ this ->assertNotEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_POST , '/ ' ));
84- $ this ->assertNotEquals ($ routePOST , Router::match (Http::REQUEST_METHOD_GET , '/ ' ));
83+ $ this ->assertNotSame ($ routeGET , Router::match (Http::REQUEST_METHOD_POST , '/ ' )[ 0 ] );
84+ $ this ->assertNotSame ($ routePOST , Router::match (Http::REQUEST_METHOD_GET , '/ ' )[ 0 ] );
8585 }
8686
8787 public function testCanMatchAlias (): void
@@ -93,9 +93,9 @@ public function testCanMatchAlias(): void
9393
9494 Router::addRoute ($ routeGET );
9595
96- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/target ' ));
97- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias ' ));
98- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias2 ' ));
96+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/target ' )[ 0 ] ?? null );
97+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias ' )[ 0 ] ?? null );
98+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias2 ' )[ 0 ] ?? null );
9999 }
100100
101101 public function testCanMatchMultipleAliases (): void
@@ -108,10 +108,10 @@ public function testCanMatchMultipleAliases(): void
108108
109109 Router::addRoute ($ routeGET );
110110
111- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/target ' ));
112- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias1 ' ));
113- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias2 ' ));
114- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias3 ' ));
111+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/target ' )[ 0 ] ?? null );
112+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias1 ' )[ 0 ] ?? null );
113+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias2 ' )[ 0 ] ?? null );
114+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/alias3 ' )[ 0 ] ?? null );
115115 }
116116
117117 public function testCanMatchMix (): void
@@ -127,22 +127,22 @@ public function testCanMatchMix(): void
127127
128128 Router::addRoute ($ routeGET );
129129
130- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/ ' ));
131- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/console ' ));
132- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/invite ' ));
133- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/login ' ));
134- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/recover ' ));
135- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/console/lorem/ipsum/dolor ' ));
136- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/auth/lorem/ipsum ' ));
137- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/register/lorem/ipsum ' ));
130+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/ ' )[ 0 ] ?? null );
131+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/console ' )[ 0 ] ?? null );
132+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/invite ' )[ 0 ] ?? null );
133+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/login ' )[ 0 ] ?? null );
134+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/recover ' )[ 0 ] ?? null );
135+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/console/lorem/ipsum/dolor ' )[ 0 ] ?? null );
136+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/auth/lorem/ipsum ' )[ 0 ] ?? null );
137+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/register/lorem/ipsum ' )[ 0 ] ?? null );
138138 }
139139
140140 public function testCanMatchFilename (): void
141141 {
142142 $ routeGET = new Route (Http::REQUEST_METHOD_GET , '/robots.txt ' );
143143
144144 Router::addRoute ($ routeGET );
145- $ this ->assertEquals ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/robots.txt ' ));
145+ $ this ->assertSame ($ routeGET , Router::match (Http::REQUEST_METHOD_GET , '/robots.txt ' )[ 0 ] ?? null );
146146 }
147147
148148 public function testCannotFindUnknownRouteByPath (): void
@@ -156,7 +156,7 @@ public function testCannotFindUnknownRouteByMethod(): void
156156
157157 Router::addRoute ($ route );
158158
159- $ this ->assertEquals ($ route , Router::match (Http::REQUEST_METHOD_GET , '/404 ' ));
159+ $ this ->assertSame ($ route , Router::match (Http::REQUEST_METHOD_GET , '/404 ' )[ 0 ] ?? null );
160160
161161 $ this ->assertNull (Router::match (Http::REQUEST_METHOD_POST , '/404 ' ));
162162 }
0 commit comments