Add 'classes' option to add extra classes

This commit is contained in:
Brabli
2023-01-03 10:58:16 +00:00
parent d5278f3473
commit 87a6204f25
2 changed files with 45 additions and 13 deletions

View File

@@ -300,6 +300,26 @@ class IconExtensionTest extends TestCase
$this->assertMatchesRegularExpression('/<svg.+class=".*group-hover:stroke-white.*".*>/', $contents);
}
public function testExtraClassesThrowsIfNotAnArray(): void
{
$this->expectException(\TypeError::class);
$this->icon->renderIcon(['icon' => self::ICON, 'classes' => 'string_value']);
}
public function testExtraClassesGetAdded(): void
{
$contents = $this->icon->renderIcon(['icon' => self::ICON, 'classes' => ['abc', 'def']]);
$this->assertMatchesRegularExpression('/<svg.+class=".*abc.*".*>/', $contents);
$this->assertMatchesRegularExpression('/<svg.+class=".*def.*".*>/', $contents);
}
public function testAddingExtraClassesDoesntStripAwayColourClasses(): void
{
$contents = $this->icon->renderIcon(['icon' => self::ICON, 'classes' => ['abc']]);
$this->assertMatchesRegularExpression('/<svg.+class=".*abc.*".*>/', $contents);
$this->assertMatchesRegularExpression('/<svg.+class=".*fill-primary.*".*>/', $contents);
}
public function testThrowsIfInvalidOptionPassed(): void
{
$this->expectException(\InvalidArgumentException::class);