‪TYPO3CMS  ‪main
TelephoneLinkHandlerTest.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 
28 final class ‪TelephoneLinkHandlerTest extends UnitTestCase
29 {
33  public static function ‪resolveParametersForNonFilesDataProvider(): array
34  {
35  return [
36  'telephone number with protocol' => [
37  [
38  'telephone' => 'tel:012345678',
39  ],
40  [
41  'telephone' => '012345678',
42  ],
43  'tel:012345678',
44  ],
45  'telephone number with protocol and spaces' => [
46  [
47  'telephone' => 'tel:+49 123 45 56 78',
48  ],
49  [
50  'telephone' => '+49 123 45 56 78',
51  ],
52  'tel:+49123455678',
53  ],
54  'invalid telephone number' => [
55  [
56  'telephone' => 'tel:+43-hello-world',
57  ],
58  [
59  'telephone' => '+43-hello-world',
60  ],
61  'tel:+43',
62  ],
63  'telephone number with weird characters' => [
64  [
65  'telephone' => 'tel:+43/123!45&56%78',
66  ],
67  [
68  'telephone' => '+43/123!45&56%78',
69  ],
70  'tel:+43123455678',
71  ],
72  'telephone number with comma and semicolon' => [
73  [
74  'telephone' => 'tel:+43 123 45 56 78,; 1234',
75  ],
76  [
77  'telephone' => '+43 123 45 56 78,; 1234',
78  ],
79  'tel:+43123455678,;1234',
80  ],
81  ];
82  }
83 
84  #[DataProvider('resolveParametersForNonFilesDataProvider')]
85  #[Test]
86  public function ‪resolveReturnsSplitParameters(array $input, array $expected): void
87  {
88  $subject = new ‪TelephoneLinkHandler();
89  self::assertEquals($expected, $subject->resolveHandlerData($input));
90  }
91 
92  #[DataProvider('resolveParametersForNonFilesDataProvider')]
93  #[Test]
94  public function ‪splitParametersToUnifiedIdentifier(array $input, array $parameters, string $expected): void
95  {
96  $subject = new ‪TelephoneLinkHandler();
97  self::assertEquals($expected, $subject->asString($parameters));
98  }
99 }