‪TYPO3CMS  ‪main
EmailLinkHandlerTest.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 ‪EmailLinkHandlerTest extends UnitTestCase
26 {
30  public static function ‪resolveParametersForNonFilesDataProvider(): array
31  {
32  return [
33  'email without protocol' => [
34  [
35  'email' => 'one@example.com',
36  ],
37  [
38  'email' => 'one@example.com',
39  ],
40  'mailto:one@example.com',
41  ],
42  'email with protocol' => [
43  [
44  'email' => 'mailto:one@example.com',
45  ],
46  [
47  'email' => 'one@example.com',
48  ],
49  'mailto:one@example.com',
50  ],
51  'email with protocol 2' => [
52  [
53  'email' => 'mailto:info@example.org',
54  ],
55  [
56  'email' => 'info@example.org',
57  ],
58  'mailto:info@example.org',
59  ],
60  ];
61  }
62 
69  #[DataProvider('resolveParametersForNonFilesDataProvider')]
70  #[Test]
71  public function ‪resolveReturnsSplitParameters($input, $expected, $finalString): void
72  {
73  $subject = new ‪EmailLinkHandler();
74  self::assertEquals($expected, $subject->resolveHandlerData($input));
75  }
76 
83  #[DataProvider('resolveParametersForNonFilesDataProvider')]
84  #[Test]
85  public function ‪splitParametersToUnifiedIdentifier($input, $parameters, $expected): void
86  {
87  $subject = new ‪EmailLinkHandler();
88  self::assertEquals($expected, $subject->asString($parameters));
89  }
90 }