Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Use telephone as fallback for link text
Resolves: #102139 Releases: main, 12.4 Change-Id: I9eb3b759de4af5c322aedc96df169aa7c603add6 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83427 Reviewed-by: Oliver Bartsch <bo@cedev.de> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: core-ci <typo3@b13.com>
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
typo3/sysext/frontend/Tests/Unit/Typolink/TelephoneLinkBuilderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
namespace TYPO3\CMS\Frontend\Tests\Unit\Typolink; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use TYPO3\CMS\Frontend\Typolink\TelephoneLinkBuilder; | ||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase; | ||
|
||
final class TelephoneLinkBuilderTest extends UnitTestCase | ||
{ | ||
#[Test] | ||
public function noLinkTextForMissingDetailAndNoLinkTextProvided(): void | ||
{ | ||
$linkDetails = [ | ||
'type' => 'telephone', | ||
'typoLinkParameter' => 'tel:+49 221 4710 999', | ||
]; | ||
$subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false); | ||
$actualResult = $subject->build($linkDetails, '', '', []); | ||
self::assertSame('', $actualResult->getLinkText()); | ||
} | ||
|
||
#[Test] | ||
public function respectsProvidedLinkText(): void | ||
{ | ||
$linkDetails = [ | ||
'type' => 'telephone', | ||
'typoLinkParameter' => 'tel:+49 221 4710 999', | ||
]; | ||
$subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false); | ||
$actualResult = $subject->build($linkDetails, 'Phone number', '', []); | ||
self::assertSame('Phone number', $actualResult->getLinkText()); | ||
} | ||
|
||
#[Test] | ||
public function fallsBackToPhoneNumberOnMissingLinkText(): void | ||
{ | ||
$linkDetails = [ | ||
'type' => 'telephone', | ||
'typoLinkParameter' => 'tel:+49 221 4710 999', | ||
'telephone' => '+49 221 4710 999', | ||
]; | ||
$subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false); | ||
$actualResult = $subject->build($linkDetails, '', '', []); | ||
self::assertSame('+49 221 4710 999', $actualResult->getLinkText()); | ||
} | ||
|
||
#[Test] | ||
public function respectsProvidedLinkParameter(): void | ||
{ | ||
$linkDetails = [ | ||
'type' => 'telephone', | ||
'typoLinkParameter' => 'tel:+49 221 4710 999', | ||
]; | ||
$subject = $this->getAccessibleMock(TelephoneLinkBuilder::class, null, [], '', false); | ||
$actualResult = $subject->build($linkDetails, '', '', []); | ||
self::assertSame('tel:+49 221 4710 999', $actualResult->getUrl()); | ||
} | ||
} |