assertTrue((new Markup('
', 'UTF-8'))->isSafeFor('js')); } /** * @dataProvider provideSafeStrategies */ #[DataProvider('provideSafeStrategies')] public function testContentIsSafeForTheGivenStrategies(bool $safe, array $safeStrategies, string $strategy): void { $this->assertSame($safe, (new Markup('
', 'UTF-8', $safeStrategies))->isSafeFor($strategy)); } public static function provideSafeStrategies(): iterable { yield [true, ['all'], 'js']; yield [true, ['html', 'js'], 'js']; yield [false, ['html', 'js'], 'css']; yield [true, ['html_attr'], 'html']; yield [true, ['html_attr'], 'html_attr_relaxed']; yield [false, ['html'], 'html_attr']; yield [false, [], 'html']; } public function testWithContentKeepsTheSafeStrategies(): void { $markup = (new Markup('
', 'UTF-8', ['html']))->withContent('
'); $this->assertSame('
', (string) $markup); $this->assertTrue($markup->isSafeFor('html')); $this->assertFalse($markup->isSafeFor('js')); } }