‪TYPO3CMS  10.4
RedirectServiceTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Prophecy\Argument;
21 use Prophecy\Prophecy\ObjectProphecy;
22 use Psr\Log\LoggerInterface;
33 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
34 
35 class ‪RedirectServiceTest extends UnitTestCase
36 {
40  protected ‪$resetSingletonInstances = true;
41 
46 
50  protected ‪$linkServiceProphecy;
51 
56 
60  protected ‪$siteFinder;
61 
62  protected function ‪setUp(): void
63  {
64  parent::setUp();
65  $loggerProphecy = $this->prophesize(LoggerInterface::class);
66  $this->redirectCacheServiceProphecy = $this->prophesize(RedirectCacheService::class);
67  $this->linkServiceProphecy = $this->prophesize(LinkService::class);
68  $this->siteFinder = $this->prophesize(SiteFinder::class);
69 
70  $this->redirectService = new ‪RedirectService($this->redirectCacheServiceProphecy->reveal(), $this->linkServiceProphecy->reveal(), $this->siteFinder->reveal());
71  $this->redirectService->setLogger($loggerProphecy->reveal());
72 
73  ‪$GLOBALS['SIM_ACCESS_TIME'] = 42;
74  }
75 
80  {
81  $this->redirectCacheServiceProphecy->getRedirects()->willReturn([]);
82 
83  $result = $this->redirectService->matchRedirect('example.com', 'foo');
84 
85  self::assertNull($result);
86  }
87 
93  public function ‪matchRedirectReturnsRedirectOnFlatMatch(string $path = '')
94  {
95  $row = [
96  'target' => 'https://example.com',
97  'force_https' => '0',
98  'keep_query_parameters' => '0',
99  'target_statuscode' => '307',
100  'disabled' => '0',
101  'starttime' => '0',
102  'endtime' => '0'
103  ];
104  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
105  [
106  'example.com' => [
107  'flat' => [
108  $path . '/' => [
109  1 => $row,
110  ],
111  ],
112  ],
113  ]
114  );
115 
116  $result = $this->redirectService->matchRedirect('example.com', rawurlencode($path));
117 
118  self::assertSame($row, $result);
119  }
120 
125  {
126  return [
127  'default case' => [
128  'foo'
129  ],
130  'umlauts' => [
131  'äöü'
132  ],
133  'various special chars' => [
134  'special-chars-«-∑-€-®-†-Ω-¨-ø-π-å-‚-∂-ƒ-©-ª-º-∆-@-¥-≈-ç-√-∫-~-µ-∞-…-–'
135  ],
136  'chinese' => [
137  '应用'
138  ],
139  'hindi' => [
140  'कंपनी'
141  ],
142  'cyrilic' => [
143  'cyrilic-АВГДЄЅЗИѲІКЛМНѮѺПЧ',
144  ],
145  ];
146  }
147 
152  {
153  $row = [
154  'target' => 'https://example.com',
155  'force_https' => '0',
156  'keep_query_parameters' => '0',
157  'respect_query_parameters' => '1',
158  'target_statuscode' => '307',
159  'disabled' => '0',
160  'starttime' => '0',
161  'endtime' => '0'
162  ];
163  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
164  [
165  'example.com' => [
166  'respect_query_parameters' => [
167  'index.php?id=123' => [
168  1 => $row,
169  ],
170  ],
171  ],
172  ]
173  );
174 
175  $result = $this->redirectService->matchRedirect('example.com', 'index.php', 'id=123');
176 
177  self::assertSame($row, $result);
178  }
179 
184  {
185  $row = [
186  'target' => 'https://example.com',
187  'force_https' => '0',
188  'keep_query_parameters' => '0',
189  'respect_query_parameters' => '1',
190  'target_statuscode' => '307',
191  'disabled' => '0',
192  'starttime' => '0',
193  'endtime' => '0'
194  ];
195  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
196  [
197  'example.com' => [
198  'respect_query_parameters' => [
199  'index.php/?id=123' => [
200  1 => $row,
201  ],
202  ],
203  ],
204  ]
205  );
206 
207  $result = $this->redirectService->matchRedirect('example.com', 'index.php', 'id=123');
208 
209  self::assertSame($row, $result);
210  }
211 
216  {
217  $row = [
218  'target' => 'https://example.com/target',
219  'force_https' => '0',
220  'keep_query_parameters' => '0',
221  'respect_query_parameters' => '1',
222  'target_statuscode' => '307',
223  'disabled' => '0',
224  'starttime' => '0',
225  'endtime' => '0'
226  ];
227  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
228  [
229  'example.com' => [
230  'respect_query_parameters' => [
231  'index.php?id=123&a=b' => [
232  1 => $row,
233  ],
234  ],
235  ],
236  ]
237  );
238 
239  $result = $this->redirectService->matchRedirect('example.com', 'index.php', 'id=123&a=b');
240 
241  self::assertSame($row, $result);
242  }
243 
248  {
249  $row = [
250  'target' => 'https://example.com/target',
251  'force_https' => '0',
252  'keep_query_parameters' => '0',
253  'respect_query_parameters' => '1',
254  'target_statuscode' => '307',
255  'disabled' => '0',
256  'starttime' => '0',
257  'endtime' => '0'
258  ];
259  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
260  [
261  'example.com' => [
262  'respect_query_parameters' => [
263  'index.php?id=123&a=b' => [
264  1 => $row,
265  ],
266  ],
267  ],
268  ]
269  );
270 
271  $result = $this->redirectService->matchRedirect('example.com', 'index.php', 'id=123&a=a');
272 
273  self::assertNull($result);
274  }
275 
280  {
281  $row1 = [
282  'target' => 'https://example.com/no-promotion',
283  'force_https' => '0',
284  'keep_query_parameters' => '0',
285  'respect_query_parameters' => '0',
286  'target_statuscode' => '307',
287  'disabled' => '0',
288  'starttime' => '0',
289  'endtime' => '0'
290  ];
291  $row2 = [
292  'target' => 'https://example.com/promotion',
293  'force_https' => '0',
294  'keep_query_parameters' => '0',
295  'respect_query_parameters' => '1',
296  'target_statuscode' => '307',
297  'disabled' => '0',
298  'starttime' => '0',
299  'endtime' => '0'
300  ];
301  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
302  [
303  'example.com' => [
304  'flat' => [
305  'special/page/' =>
306  [
307  1 => $row1,
308  ]
309  ],
310  'respect_query_parameters' => [
311  'special/page?key=998877' => [
312  1 => $row2,
313  ],
314  ],
315  ],
316  ]
317  );
318 
319  $result = $this->redirectService->matchRedirect('example.com', 'special/page', 'key=998877');
320 
321  self::assertSame($row2, $result);
322  }
323 
328  {
329  $row1 = [
330  'target' => 'https://example.com',
331  'force_https' => '0',
332  'keep_query_parameters' => '0',
333  'target_statuscode' => '307',
334  'disabled' => '0',
335  'starttime' => '0',
336  'endtime' => '0'
337  ];
338  $row2 = [
339  'target' => 'https://example.net',
340  'force_https' => '0',
341  'keep_query_parameters' => '0',
342  'target_statuscode' => '307',
343  'disabled' => '0',
344  'starttime' => '0',
345  'endtime' => '0'
346  ];
347  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
348  [
349  'example.com' => [
350  'flat' => [
351  'foo/' => [
352  1 => $row1,
353  ],
354  ],
355  ],
356  '*' => [
357  'flat' => [
358  'foo/' => [
359  2 => $row2,
360  ],
361  ],
362  ],
363  ]
364  );
365 
366  $result = $this->redirectService->matchRedirect('example.com', 'foo');
367 
368  self::assertSame($row1, $result);
369  }
370 
375  {
376  $row = [
377  'target' => 'https://example.com',
378  'force_https' => '0',
379  'keep_query_parameters' => '0',
380  'target_statuscode' => '307',
381  'disabled' => '0',
382  'starttime' => '0',
383  'endtime' => '0'
384  ];
385  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
386  [
387  'example.com' => [
388  'regexp' => [
389  '/f.*?/' => [
390  1 => $row,
391  ],
392  ],
393  ],
394  ]
395  );
396 
397  $result = $this->redirectService->matchRedirect('example.com', 'foo');
398 
399  self::assertSame($row, $result);
400  }
401 
406  {
407  $row1 = [
408  'target' => 'https://example.com',
409  'force_https' => '0',
410  'keep_query_parameters' => '0',
411  'target_statuscode' => '307',
412  'starttime' => '0',
413  'endtime' => '0',
414  'disabled' => '1'
415  ];
416  $row2 = [
417  'target' => 'https://example.net',
418  'force_https' => '0',
419  'keep_query_parameters' => '0',
420  'target_statuscode' => '307',
421  'starttime' => '0',
422  'endtime' => '0',
423  'disabled' => '0'
424  ];
425  $this->redirectCacheServiceProphecy->getRedirects()->willReturn(
426  [
427  'example.com' => [
428  'flat' => [
429  'foo/' => [
430  1 => $row1,
431  2 => $row2
432  ],
433  ],
434  ],
435  ]
436  );
437 
438  $result = $this->redirectService->matchRedirect('example.com', 'foo');
439 
440  self::assertSame($row2, $result);
441  }
442 
447  {
448  $this->linkServiceProphecy->resolve(Argument::any())->willThrow(new ‪InvalidPathException('', 1516531195));
449 
450  $result = $this->redirectService->getTargetUrl(['target' => 'invalid'], [], new ‪FrontendUserAuthentication(), new ‪Uri(), new ‪Site('dummy', 13, []));
451 
452  self::assertNull($result);
453  }
454 
458  public function ‪getTargetUrlReturnsUrlForTypeUrl()
459  {
460  $redirectTargetMatch = [
461  'target' => 'https://example.com',
462  'force_https' => '0',
463  'keep_query_parameters' => '0'
464  ];
465  $linkDetails = [
466  'type' => ‪LinkService::TYPE_URL,
467  'url' => 'https://example.com/'
468  ];
469  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
470 
471  $source = new ‪Uri('https://example.com');
472  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, [], new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
473 
474  $uri = new ‪Uri('https://example.com/');
475  self::assertEquals($uri, $result);
476  }
477 
481  public function ‪getTargetUrlReturnsUrlForTypeFile()
482  {
483  $fileProphecy = $this->prophesize(File::class);
484  $fileProphecy->getPublicUrl()->willReturn('https://example.com/file.txt');
485  $redirectTargetMatch = [
486  'target' => 'https://example.com',
487  'force_https' => '0',
488  'keep_query_parameters' => '0',
489  ];
490  $linkDetails = [
491  'type' => ‪LinkService::TYPE_FILE,
492  'file' => $fileProphecy->reveal()
493  ];
494  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
495 
496  $source = new ‪Uri('https://example.com');
497  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, [], new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
498 
499  $uri = new ‪Uri('https://example.com/file.txt');
500  self::assertEquals($uri, $result);
501  }
502 
507  {
508  $folderProphecy = $this->prophesize(Folder::class);
509  $folderProphecy->getPublicUrl()->willReturn('https://example.com/folder/');
510  $redirectTargetMatch = [
511  'target' => 'https://example.com',
512  'force_https' => '0',
513  'keep_query_parameters' => '0',
514  ];
515  $folder = $folderProphecy->reveal();
516  $linkDetails = [
517  'type' => ‪LinkService::TYPE_FOLDER,
518  'folder' => $folder
519  ];
520  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
521 
522  $source = new ‪Uri('https://example.com/');
523  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, [], new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
524 
525  $uri = new ‪Uri('https://example.com/folder/');
526  self::assertEquals($uri, $result);
527  }
528 
532  public function ‪getTargetUrlRespectsForceHttps()
533  {
534  $redirectTargetMatch = [
535  'target' => 'https://example.com',
536  'keep_query_parameters' => '0',
537  'force_https' => '1',
538  ];
539  $linkDetails = [
540  'type' => ‪LinkService::TYPE_URL,
541  'url' => 'http://example.com'
542  ];
543  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
544 
545  $source = new ‪Uri('https://example.com');
546  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, [], new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
547 
548  $uri = new ‪Uri('https://example.com');
549  self::assertEquals($uri, $result);
550  }
551 
556  {
557  $redirectTargetMatch = [
558  'target' => 'https://example.com',
559  'force_https' => '0',
560  'keep_query_parameters' => '1'
561  ];
562  $linkDetails = [
563  'type' => ‪LinkService::TYPE_URL,
564  'url' => 'https://example.com/?foo=1&bar=2'
565  ];
566  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
567 
568  $source = new ‪Uri('https://example.com/?bar=2&baz=4&foo=1');
569  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, ['bar' => 3, 'baz' => 4], new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
570 
571  $uri = new ‪Uri('https://example.com/?bar=2&baz=4&foo=1');
572  self::assertEquals($uri, $result);
573  }
574 
579  {
581  ‪$redirectService = $this->getAccessibleMock(
582  RedirectService::class,
583  ['getUriFromCustomLinkDetails'],
584  [$this->redirectCacheServiceProphecy->reveal(), $this->linkServiceProphecy->reveal(), $this->siteFinder->reveal()],
585  '',
586  true
587  );
588 
589  $loggerProphecy = $this->prophesize(LoggerInterface::class);
590  ‪$redirectService->setLogger($loggerProphecy->reveal());
591 
592  $pageRecord = 't3://page?uid=13';
593  $redirectTargetMatch = [
594  'target' => $pageRecord . ' - - - foo=bar',
595  'force_https' => 1,
596  'keep_query_parameters' => 1
597  ];
598 
599  $linkDetails = [
600  'pageuid' => 13,
601  'type' => ‪LinkService::TYPE_PAGE
602  ];
603  $this->linkServiceProphecy->resolve($pageRecord)->willReturn($linkDetails);
604 
605  $queryParams = [];
606  $queryParams['foo'] = 'bar';
607  $uri = new ‪Uri('/page?foo=bar');
608 
609  $frontendUserAuthentication = new ‪FrontendUserAuthentication();
610  $site = new ‪Site('dummy', 13, []);
611  ‪$redirectService->expects(self::once())->method('getUriFromCustomLinkDetails')
612  ->with($redirectTargetMatch, $frontendUserAuthentication, $site, $linkDetails, $queryParams)
613  ->willReturn($uri);
614  $result = ‪$redirectService->‪getTargetUrl($redirectTargetMatch, [], $frontendUserAuthentication, $uri, $site);
615 
616  self::assertEquals($uri, $result);
617  }
618 
623  {
624  $redirectTargetMatch = [
625  'source_path' => '#^/foo/(.*)#',
626  'target' => 'https://anotherdomain.com/$1',
627  'force_https' => '0',
628  'keep_query_parameters' => '1',
629  'is_regexp' => 1
630  ];
631  $linkDetails = [
632  'type' => ‪LinkService::TYPE_URL,
633  'url' => 'https://anotherdomain.com/$1'
634  ];
635  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
636 
637  $source = new ‪Uri('https://example.com/foo/bar');
638  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, [], new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
639 
640  $uri = new ‪Uri('https://anotherdomain.com/bar');
641  self::assertEquals($uri, $result);
642  }
643 
645  {
646  $cyrilicPlain = 'АВГДЄЅЗИѲІКЛМНѮѺПЧ';
647  return [
648  'index.php with query capture group - plain value' => [
649  '#^/index.php\?option=com_content&page=(.*)#',
650  'https://anotherdomain.com/$1',
651  'https://example.com/index.php?option=com_content&page=target',
652  'https://anotherdomain.com/target',
653  ],
654  'index.php with query capture group - cyrilic value' => [
655  '#^/index.php\?option=com_content&page=(.*)#',
656  'https://anotherdomain.com/$1',
657  sprintf('https://example.com/index.php?option=com_content&page=%s', $cyrilicPlain),
658  sprintf('https://anotherdomain.com/%s', $cyrilicPlain),
659  ],
660  'capture group in path and query capture group - cyrilic value' => [
661  '#^/index-(.*).php\?option=com_content&page=(.*)#',
662  'https://anotherdomain.com/$1/$2',
663  sprintf('https://example.com/index-%s.php?option=com_content&page=cyrilic-%s', $cyrilicPlain, $cyrilicPlain),
664  sprintf('https://anotherdomain.com/%s/cyrilic-%s', $cyrilicPlain, $cyrilicPlain),
665  ],
666  'cyrilic path with non-cyrilic capture group' => [
667  sprintf('#^/index-%s.php\?option=com_content&page=(.*)#', $cyrilicPlain),
668  'https://anotherdomain.com/$1',
669  sprintf('https://example.com/index-%s.php?option=com_content&page=cyrilic-%s', $cyrilicPlain, $cyrilicPlain),
670  sprintf('https://anotherdomain.com/cyrilic-%s', $cyrilicPlain),
671  ],
672  'cyrilic path with cyrilic capture group' => [
673  sprintf('#^/index-%s.php\?option=com_content&page=(.*)#', $cyrilicPlain),
674  'https://anotherdomain.com/$1',
675  sprintf('https://example.com/index-%s.php?option=com_content&page=cyrilic-%s', $cyrilicPlain, $cyrilicPlain),
676  sprintf('https://anotherdomain.com/cyrilic-%s', $cyrilicPlain),
677  ],
678  'cyrilic path with cyrilic capture group with cyrilic prefix' => [
679  sprintf('#^/index-%s.php\?option=com_content&page=%s(.*)#', $cyrilicPlain, $cyrilicPlain),
680  'https://anotherdomain.com/$1',
681  sprintf('https://example.com/index-%s.php?option=com_content&page=%scyrilic-%s', $cyrilicPlain, $cyrilicPlain, $cyrilicPlain),
682  sprintf('https://anotherdomain.com/cyrilic-%s', $cyrilicPlain),
683  ],
684  ];
685  }
686 
692  string $redirectSourcePath,
693  string $redirectTarget,
694  string $requestUri,
695  string $expectedRedirectUri
696  ) {
697  $redirectTargetMatch = [
698  'uid' => 1,
699  'source_path' => $redirectSourcePath,
700  'target' => $redirectTarget,
701  'force_https' => '0',
702  'keep_query_parameters' => 0,
703  'is_regexp' => 1,
704  'respect_query_parameters' => 1,
705  ];
706  $linkDetails = [
707  'type' => ‪LinkService::TYPE_URL,
708  'url' => $redirectTarget,
709  'query' => '',
710  ];
711  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
712 
713  $source = new ‪Uri($requestUri);
714  $queryParams = [];
715  parse_str($source->getQuery(), $queryParams);
716  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, $queryParams, new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
717 
718  $uri = new ‪Uri($expectedRedirectUri);
719  self::assertEquals($uri, $result);
720  }
721 
723  {
724  $cyrilicPlain = 'АВГДЄЅЗИѲІКЛМНѮѺПЧ';
725  return [
726  'index with path slash with query capture group - plain value' => [
727  '#^/index/\?option=com_content&page=(.*)#',
728  'https://anotherdomain.com/$1',
729  'https://example.com/index/?option=com_content&page=target',
730  'https://anotherdomain.com/target?option=com_content&page=target',
731  ],
732  'index with query capture group - cyrilic value' => [
733  '#^/index/\?option=com_content&page=(.*)#',
734  'https://anotherdomain.com/$1',
735  sprintf('https://example.com/index/?option=com_content&page=%s', $cyrilicPlain),
736  sprintf('https://anotherdomain.com/%s?option=com_content&page=%s', $cyrilicPlain, $cyrilicPlain),
737  ],
738  'capture group in path and query capture group - cyrilic value' => [
739  '#^/index-(.*)/\?option=com_content&page=(.*)#',
740  'https://anotherdomain.com/$1/$2',
741  sprintf('https://example.com/index-%s/?option=com_content&page=cyrilic-%s', $cyrilicPlain, $cyrilicPlain),
742  sprintf('https://anotherdomain.com/%s/cyrilic-%s?option=com_content&page=cyrilic-%s', $cyrilicPlain, $cyrilicPlain, $cyrilicPlain),
743  ],
744  'cyrilic path with non-cyrilic capture group' => [
745  sprintf('#^/index-%s/\?option=com_content&page=(.*)#', $cyrilicPlain),
746  'https://anotherdomain.com/$1',
747  sprintf('https://example.com/index-%s/?option=com_content&page=cyrilic', $cyrilicPlain),
748  'https://anotherdomain.com/cyrilic?option=com_content&page=cyrilic',
749  ],
750  'cyrilic path with cyrilic capture group' => [
751  sprintf('#^/index-%s/\?option=com_content&page=(.*)#', $cyrilicPlain),
752  'https://anotherdomain.com/$1',
753  sprintf('https://example.com/index-%s/?option=com_content&page=cyrilic-%s', $cyrilicPlain, $cyrilicPlain),
754  sprintf('https://anotherdomain.com/cyrilic-%s?option=com_content&page=cyrilic-%s', $cyrilicPlain, $cyrilicPlain),
755  ],
756  'cyrilic path with cyrilic capture group with cyrilic prefix' => [
757  sprintf('#^/index-%s/\?option=com_content&page=%s(.*)#', $cyrilicPlain, $cyrilicPlain),
758  'https://anotherdomain.com/$1',
759  sprintf('https://example.com/index-%s/?option=com_content&page=%scyrilic-%s', $cyrilicPlain, $cyrilicPlain, $cyrilicPlain),
760  sprintf('https://anotherdomain.com/cyrilic-%s?option=com_content&page=%scyrilic-%s', $cyrilicPlain, $cyrilicPlain, $cyrilicPlain),
761  ],
762  ];
763  }
764 
770  string $redirectSourcePath,
771  string $redirectTarget,
772  string $requestUri,
773  string $expectedRedirectUri
774  ) {
775  $redirectTargetMatch = [
776  'uid' => 1,
777  'source_path' => $redirectSourcePath,
778  'target' => $redirectTarget,
779  'force_https' => '0',
780  'keep_query_parameters' => '1',
781  'is_regexp' => 1,
782  'respect_query_parameters' => 1,
783  ];
784  $linkDetails = [
785  'type' => ‪LinkService::TYPE_URL,
786  'url' => $redirectTarget,
787  ];
788  $this->linkServiceProphecy->resolve($redirectTargetMatch['target'])->willReturn($linkDetails);
789 
790  $source = new ‪Uri($requestUri);
791  $queryParams = [];
792  parse_str($source->getQuery(), $queryParams);
793  $result = $this->redirectService->getTargetUrl($redirectTargetMatch, $queryParams, new ‪FrontendUserAuthentication(), $source, new ‪Site('dummy', 13, []));
794 
795  $uri = new ‪Uri($expectedRedirectUri);
796  self::assertEquals($uri, $result);
797  }
798 }
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlReplaceRegExpCaptureGroup
‪getTargetUrlReplaceRegExpCaptureGroup()
Definition: RedirectServiceTest.php:617
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlWithQueryReplaceRegExpCaptureGroup
‪getTargetUrlWithQueryReplaceRegExpCaptureGroup(string $redirectSourcePath, string $redirectTarget, string $requestUri, string $expectedRedirectUri)
Definition: RedirectServiceTest.php:686
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlWithQueryAndSlashReplaceRegExpCaptureGroup
‪getTargetUrlWithQueryAndSlashReplaceRegExpCaptureGroup(string $redirectSourcePath, string $redirectTarget, string $requestUri, string $expectedRedirectUri)
Definition: RedirectServiceTest.php:764
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\$siteFinder
‪SiteFinder $siteFinder
Definition: RedirectServiceTest.php:55
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest
Definition: RedirectServiceTest.php:36
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsNullIfNoRedirectsExist
‪matchRedirectReturnsNullIfNoRedirectsExist()
Definition: RedirectServiceTest.php:74
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlReturnsUrlForTypeUrl
‪getTargetUrlReturnsUrlForTypeUrl()
Definition: RedirectServiceTest.php:453
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsRedirectSpecificToDomainOnFlatMatchIfSpecificAndNonSpecificExist
‪matchRedirectReturnsRedirectSpecificToDomainOnFlatMatchIfSpecificAndNonSpecificExist()
Definition: RedirectServiceTest.php:322
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlRespectsAdditionalParametersFromTypolink
‪getTargetUrlRespectsAdditionalParametersFromTypolink()
Definition: RedirectServiceTest.php:573
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsRedirectOnRespectQueryParametersMatchWithSlash
‪matchRedirectReturnsRedirectOnRespectQueryParametersMatchWithSlash()
Definition: RedirectServiceTest.php:178
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlWithQueryAndSlashReplaceRegExpCaptureGroupDataProvider
‪getTargetUrlWithQueryAndSlashReplaceRegExpCaptureGroupDataProvider()
Definition: RedirectServiceTest.php:717
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsOnlyActiveRedirects
‪matchRedirectReturnsOnlyActiveRedirects()
Definition: RedirectServiceTest.php:400
‪TYPO3\CMS\Redirects\Service\RedirectService
Definition: RedirectService.php:48
‪TYPO3\CMS\Core\Site\SiteFinder
Definition: SiteFinder.php:31
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsRedirectOnRespectQueryParametersMatch
‪matchRedirectReturnsRedirectOnRespectQueryParametersMatch()
Definition: RedirectServiceTest.php:146
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\$redirectCacheServiceProphecy
‪RedirectCacheService ObjectProphecy $redirectCacheServiceProphecy
Definition: RedirectServiceTest.php:43
‪TYPO3\CMS\Redirects\Tests\Unit\Service
Definition: RedirectServiceTest.php:18
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsRedirectOnFlatMatch
‪matchRedirectReturnsRedirectOnFlatMatch(string $path='')
Definition: RedirectServiceTest.php:88
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlReturnsNullIfUrlCouldNotBeResolved
‪getTargetUrlReturnsNullIfUrlCouldNotBeResolved()
Definition: RedirectServiceTest.php:441
‪TYPO3\CMS\Core\Http\Uri
Definition: Uri.php:29
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:40
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\setUp
‪setUp()
Definition: RedirectServiceTest.php:57
‪TYPO3\CMS\Redirects\Service\RedirectCacheService
Definition: RedirectCacheService.php:33
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsMatchingRedirectWithMatchingQueryParametersOverMatchingPath
‪matchRedirectReturnsMatchingRedirectWithMatchingQueryParametersOverMatchingPath()
Definition: RedirectServiceTest.php:274
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: RedirectServiceTest.php:39
‪TYPO3\CMS\Redirects\Service\RedirectService\getTargetUrl
‪UriInterface null getTargetUrl(array $matchedRedirect, array $queryParams, FrontendUserAuthentication $frontendUserAuthentication, UriInterface $uri, ?SiteInterface $site=null)
Definition: RedirectService.php:234
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlWithQueryReplaceRegExpCaptureGroupDataProvider
‪getTargetUrlWithQueryReplaceRegExpCaptureGroupDataProvider()
Definition: RedirectServiceTest.php:639
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\$redirectService
‪RedirectService $redirectService
Definition: RedirectServiceTest.php:51
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsRedirectOnFullRespectQueryParametersMatch
‪matchRedirectReturnsRedirectOnFullRespectQueryParametersMatch()
Definition: RedirectServiceTest.php:210
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlReturnsUrlForTypeFile
‪getTargetUrlReturnsUrlForTypeFile()
Definition: RedirectServiceTest.php:476
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsRedirectOnFlatMatchDataProvider
‪array matchRedirectReturnsRedirectOnFlatMatchDataProvider()
Definition: RedirectServiceTest.php:119
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlAddsExistingQueryParams
‪getTargetUrlAddsExistingQueryParams()
Definition: RedirectServiceTest.php:550
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsNullOnPartialRespectQueryParametersMatch
‪matchRedirectReturnsNullOnPartialRespectQueryParametersMatch()
Definition: RedirectServiceTest.php:242
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\matchRedirectReturnsRedirectOnRegexMatch
‪matchRedirectReturnsRedirectOnRegexMatch()
Definition: RedirectServiceTest.php:369
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlReturnsUrlForTypeFolder
‪getTargetUrlReturnsUrlForTypeFolder()
Definition: RedirectServiceTest.php:501
‪TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication
Definition: FrontendUserAuthentication.php:30
‪TYPO3\CMS\Core\Resource\Exception\InvalidPathException
Definition: InvalidPathException.php:24
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\$linkServiceProphecy
‪LinkService ObjectProphecy $linkServiceProphecy
Definition: RedirectServiceTest.php:47
‪TYPO3\CMS\Redirects\Tests\Unit\Service\RedirectServiceTest\getTargetUrlRespectsForceHttps
‪getTargetUrlRespectsForceHttps()
Definition: RedirectServiceTest.php:527