forked from OpenMage/magento-lts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
dev/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.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,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenMage\Tests\Unit\Mage\Core\Model\Security; | ||
|
||
use Mage_Core_Model_Security_HtmlEscapedString; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class HtmlEscapedStringTest extends TestCase | ||
{ | ||
public const TEST_STRING = 'This is a bold <b>string></b>'; | ||
|
||
/** | ||
* @var Mage_Core_Model_Security_HtmlEscapedString | ||
*/ | ||
public Mage_Core_Model_Security_HtmlEscapedString $subject; | ||
|
||
/** | ||
* @dataProvider provideHtmlEscapedStringAsStringData | ||
* @param string $expectedResult | ||
* @param string $string | ||
* @param string|array<int, string> $allowedTags | ||
* @return void | ||
*/ | ||
public function test__toSting(string $expectedResult, string $string, ?array $allowedTags): void | ||
Check failure on line 26 in dev/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php GitHub Actions / PHPStan / Analyze (ubuntu-latest, 8.3)
|
||
{ | ||
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation | ||
$this->subject = new Mage_Core_Model_Security_HtmlEscapedString($string, $allowedTags); | ||
$this->assertSame($expectedResult, (string) $this->subject); | ||
} | ||
|
||
/** | ||
* @dataProvider provideHtmlEscapedStringGetUnescapedValueData | ||
* @param string $expectedResult | ||
* @param string $string | ||
* @param string|array<int, string> $allowedTags | ||
* @return void | ||
*/ | ||
public function testGetUnescapedValue(string $expectedResult, string $string, ?array $allowedTags): void | ||
Check failure on line 40 in dev/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php GitHub Actions / PHPStan / Analyze (ubuntu-latest, 8.3)
|
||
{ | ||
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation | ||
$this->subject = new Mage_Core_Model_Security_HtmlEscapedString($string, $allowedTags); | ||
$this->assertSame($expectedResult, $this->subject->getUnescapedValue()); | ||
} | ||
|
||
/** | ||
* @return array<string, array<int, int|string>> | ||
*/ | ||
public function provideHtmlEscapedStringAsStringData(): array | ||
{ | ||
return [ | ||
Check failure on line 52 in dev/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php GitHub Actions / PHPStan / Analyze (ubuntu-latest, 8.3)
|
||
'tags_null' => [ | ||
'This is a bold <b>string></b>', | ||
'This is a bold <b>string></b>', | ||
null | ||
], | ||
// 'tags_array' => [ | ||
// 'This is a bold <b>string></b>', | ||
// 'This is a bold <b>string></b>', | ||
// ['b'] | ||
// ], | ||
]; | ||
} | ||
|
||
/** | ||
* @return array<string, array<int, int|string>> | ||
*/ | ||
public function provideHtmlEscapedStringGetUnescapedValueData(): array | ||
{ | ||
return [ | ||
Check failure on line 71 in dev/tests/unit/Mage/Core/Model/Security/HtmlEscapedStringTest.php GitHub Actions / PHPStan / Analyze (ubuntu-latest, 8.3)
|
||
'tags_null' => [ | ||
self::TEST_STRING, | ||
self::TEST_STRING, | ||
null | ||
], | ||
'tags_array' => [ | ||
self::TEST_STRING, | ||
self::TEST_STRING, | ||
['some-invalid-value'] | ||
], | ||
]; | ||
} | ||
} |