diff --git a/src/PcmIconBundle.php b/src/PcmIconBundle.php index 17eb2ce..ff510f5 100644 --- a/src/PcmIconBundle.php +++ b/src/PcmIconBundle.php @@ -5,10 +5,7 @@ declare(strict_types=1); namespace Pcm\IconBundle; use Pcm\IconBundle\DependencyInjection\PcmIconExtension; -use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\HttpKernel\Bundle\AbstractBundle; class PcmIconBundle extends AbstractBundle diff --git a/src/Twig/Extension/IconExtension.php b/src/Twig/Extension/IconExtension.php new file mode 100644 index 0000000..1732b96 --- /dev/null +++ b/src/Twig/Extension/IconExtension.php @@ -0,0 +1,22 @@ + ['html'] - ]) - ]; - } - /** * @param array $options * ``` @@ -211,7 +200,3 @@ final class IconExtension extends AbstractExtension } } } - -class IconNotFound extends \Exception {}; - -class ColourNotFound extends \Exception {}; diff --git a/tests/Twig/Functions/IconExtensionTest.php b/tests/Twig/Runtime/IconRuntimeTest.php similarity index 95% rename from tests/Twig/Functions/IconExtensionTest.php rename to tests/Twig/Runtime/IconRuntimeTest.php index 337b1a0..f8ca7c6 100644 --- a/tests/Twig/Functions/IconExtensionTest.php +++ b/tests/Twig/Runtime/IconRuntimeTest.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace Pcm\IconBundle\Tests\Twig\Functions; -use Pcm\IconBundle\Twig\Functions\IconExtension; -use Pcm\IconBundle\Twig\Functions\IconNotFound; -use Pcm\IconBundle\Twig\Functions\ColourNotFound; +use Pcm\IconBundle\Exception\ColourNotFound; +use Pcm\IconBundle\Exception\IconNotFound; +use Pcm\IconBundle\Twig\Runtime\IconRuntime; use PHPUnit\Framework\TestCase; -class IconExtensionTest extends TestCase +class IconRuntimeTest extends TestCase { private const ICON = 'test'; @@ -32,11 +32,14 @@ class IconExtensionTest extends TestCase ] ]; - private IconExtension $icon; + private IconRuntime $icon; protected function setUp(): void { - $this->icon = new IconExtension(['tests/icons'], self::COLOURS); + $this->icon = new IconRuntime( + directories: ['tests/icons'], + colours: self::COLOURS + ); } public function testThrowsWhenPassedAnInvalidIconName(): void @@ -119,7 +122,7 @@ class IconExtensionTest extends TestCase public function testDefaultSizeIsSetOnSvgIfNoSizeOptionPassed(): void { - $defaultSize = IconExtension::DEFAULT_SIZE; + $defaultSize = IconRuntime::DEFAULT_SIZE; $content = $this->icon->renderIcon(['icon' => self::ICON]); $regex = "/^icon->renderIcon(['icon' => self::ICON]); $widthRegex = "/width=\"{$defaultSize}\"/";