Make sure required keys exist in pallete arrays
This commit is contained in:
@@ -41,7 +41,14 @@ final class IconExtension extends AbstractExtension
|
||||
throw new \TypeError('Palletes array must only contain arrays!');
|
||||
|
||||
foreach ($this->palletes as $pallete) {
|
||||
if (!(array_key_exists('stroke', $pallete) && array_key_exists('fill', $pallete))) {
|
||||
if (!(
|
||||
array_key_exists('stroke', $pallete) &&
|
||||
array_key_exists('fill', $pallete) &&
|
||||
array_key_exists('fill-hover', $pallete) &&
|
||||
array_key_exists('stroke-hover', $pallete) &&
|
||||
array_key_exists('fill-group-hover', $pallete) &&
|
||||
array_key_exists('stroke-group-hover', $pallete))
|
||||
) {
|
||||
throw new \Exception('Palletes must contain a "stroke" and "fill" key!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,20 @@ class IconExtensionTest extends TestCase
|
||||
|
||||
private const PALLETES = [
|
||||
'primary' => [
|
||||
'fill' => 'fill-primary',
|
||||
'stroke' => 'stroke-primary',
|
||||
'fill' => 'fill-primary'
|
||||
'fill-hover' => 'hover:fill-primary',
|
||||
'stroke-hover' => 'hover:stroke-primary',
|
||||
'fill-group-hover' => 'group-hover:fill-primary',
|
||||
'stroke-group-hover' => 'group-hover:stroke-primary',
|
||||
],
|
||||
'white' => [
|
||||
'fill' => 'fill-white',
|
||||
'stroke' => 'stroke-white',
|
||||
'fill' => 'fill-white'
|
||||
'fill-hover' => 'hover:fill-white',
|
||||
'stroke-hover' => 'hover:stroke-white',
|
||||
'fill-group-hover' => 'group-hover:fill-white',
|
||||
'stroke-group-hover' => 'group-hover:stroke-white',
|
||||
]
|
||||
];
|
||||
|
||||
@@ -182,13 +190,37 @@ class IconExtensionTest extends TestCase
|
||||
public function testThrowsIfChildArrayDoesntContainStrokeKey(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
new IconExtension(['/'], [['fill' => '']]);
|
||||
new IconExtension(['/'], [['fill' => '', 'fill-hover' => '', 'stroke-hover' => '', 'fill-group-hover' => '', 'stroke-group-hover' => '']]);
|
||||
}
|
||||
|
||||
public function testThrowsIfChildArrayDoesntContainFillKey(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
new IconExtension(['/'], [['stroke' => '']]);
|
||||
new IconExtension(['/'], [['stroke' => '', 'fill-hover' => '', 'stroke-hover' => '', 'fill-group-hover' => '', 'stroke-group-hover' => '']]);
|
||||
}
|
||||
|
||||
public function testThrowsIfChildArrayDoesntContainFillHoverKey(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
new IconExtension(['/'], [['fill' => '', 'stroke' => '', 'stroke-hover' => '', 'fill-group-hover' => '', 'stroke-group-hover' => '']]);
|
||||
}
|
||||
|
||||
public function testThrowsIfChildArrayDoesntContainStrokeHoverKey(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
new IconExtension(['/'], [['fill' => '', 'stroke' => '', 'fill-hover' => '', 'fill-group-hover' => '', 'stroke-group-hover' => '']]);
|
||||
}
|
||||
|
||||
public function testThrowsIfChildArrayDoesntContainFillGroupHoverKey(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
new IconExtension(['/'], [['fill' => '', 'stroke' => '', 'fill-hover' => '', 'stroke-hover' => '', 'stroke-group-hover' => '']]);
|
||||
}
|
||||
|
||||
public function testThrowsIfChildArrayDoesntContainStrokeGroupHoverKey(): void
|
||||
{
|
||||
$this->expectException(\Exception::class);
|
||||
new IconExtension(['/'], [['fill' => '', 'stroke' => '', 'fill-hover' => '', 'stroke-hover' => '', 'fill-group-hover' => '']]);
|
||||
}
|
||||
|
||||
public function testBlackStrokeAttributeValuesAreRemoved(): void
|
||||
|
||||
Reference in New Issue
Block a user