‪TYPO3CMS  ‪main
TelephoneLinkBuilderTest.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\Test;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 final class ‪TelephoneLinkBuilderTest extends UnitTestCase
25 {
26  #[Test]
28  {
29  $linkDetails = [
30  'type' => 'telephone',
31  'typoLinkParameter' => 'tel:+49 221 4710 999',
32  ];
33  $subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false);
34  $actualResult = $subject->build($linkDetails, '', '', []);
35  self::assertSame('', $actualResult->getLinkText());
36  }
37 
38  #[Test]
39  public function ‪respectsProvidedLinkText(): void
40  {
41  $linkDetails = [
42  'type' => 'telephone',
43  'typoLinkParameter' => 'tel:+49 221 4710 999',
44  ];
45  $subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false);
46  $actualResult = $subject->build($linkDetails, 'Phone number', '', []);
47  self::assertSame('Phone number', $actualResult->getLinkText());
48  }
49 
50  #[Test]
52  {
53  $linkDetails = [
54  'type' => 'telephone',
55  'typoLinkParameter' => 'tel:+49 221 4710 999',
56  'telephone' => '+49 221 4710 999',
57  ];
58  $subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false);
59  $actualResult = $subject->build($linkDetails, '', '', []);
60  self::assertSame('+49 221 4710 999', $actualResult->getLinkText());
61  }
62 
63  #[Test]
64  public function ‪respectsProvidedLinkParameter(): void
65  {
66  $linkDetails = [
67  'type' => 'telephone',
68  'typoLinkParameter' => 'tel:+49 221 4710 999',
69  ];
70  $subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false);
71  $actualResult = $subject->build($linkDetails, '', '', []);
72  self::assertSame('tel:+49 221 4710 999', $actualResult->getUrl());
73  }
74 }