‪TYPO3CMS  ‪main
PageLinkHandlerTest.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 PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 final class ‪PageLinkHandlerTest extends UnitTestCase
26 {
30  public static function ‪resolveParametersForNonFilesDataProvider(): array
31  {
32  return [
33  'current page - cool style' => [
34  [
35  'uid' => 'current',
36  ],
37  [
38  'pageuid' => 'current',
39  ],
40  't3://page?uid=current',
41  ],
42  'current empty page - cool style' => [
43  [
44 
45  ],
46  [
47  'pageuid' => 'current',
48  ],
49  't3://page?uid=current',
50  ],
51  'simple page - cool style' => [
52  [
53  'uid' => '13',
54  ],
55  [
56  'pageuid' => 13,
57  ],
58  't3://page?uid=13',
59  ],
60  ];
61  }
62 
63  #[DataProvider('resolveParametersForNonFilesDataProvider')]
64  #[Test]
65  public function ‪resolveReturnsSplitParameters(array $input, array $expected, string $finalString): void
66  {
67  $subject = new ‪PageLinkHandler();
68  // fragment it is processed outside handler data
69  if (isset($expected['fragment'])) {
70  unset($expected['fragment']);
71  }
72  self::assertSame($expected, $subject->resolveHandlerData($input));
73  }
74 
75  #[DataProvider('resolveParametersForNonFilesDataProvider')]
76  #[Test]
77  public function ‪splitParametersToUnifiedIdentifier(array $input, array $parameters, string $expected): void
78  {
79  $subject = new ‪PageLinkHandler();
80  self::assertEquals($expected, $subject->asString($parameters));
81  }
82 }