helper = Bootstrap::getObjectManager()->create(Admin::class); } /** * @param string $data * @param string $expected * @param null|array $allowedTags * @return void * * @dataProvider escapeHtmlWithLinksDataProvider */ public function testEscapeHtmlWithLinks(string $data, string $expected, $allowedTags = null): void { $actual = $this->helper->escapeHtmlWithLinks($data, $allowedTags); $this->assertEquals($expected, $actual); } /** * @return array */ public function escapeHtmlWithLinksDataProvider(): array { return [ [ 'some text in tags', '<a>some text in tags</a>', 'allowedTags' => null, ], [ // @codingStandardsIgnoreStart 'Authorized amount of €30.00. Transaction ID: "123456789QWERTY"', 'Authorized amount of €30.00. Transaction ID: "123456789QWERTY"', // @codingStandardsIgnoreEnd 'allowedTags' => ['b', 'br', 'strong', 'i', 'u', 'a'], ], [ 'Transaction ID: "XX123XX"', 'Transaction ID: "XX123XX"', 'allowedTags' => ['b', 'br', 'strong', 'i', 'u', 'a'], ], [ 'some text in tags', 'some text in tags', 'allowedTags' => ['a'], ], [ "", 'alert(1)', 'allowedTags' => ['a'], ], [ 'Foo', 'Foo', 'allowedTags' => ['a'], ], [ "Foo", 'Foo', 'allowedTags' => ['a'], ], [ "Foo", 'Foo', 'allowedTags' => ['a'], ], [ "Foo", 'Foo', 'allowedTags' => ['a'], ], [ "Foo", 'Foo', 'allowedTags' => ['a'], ], ]; } }