Split extension into extension and runtime classes to match how the maker bundle creates twig extensions
This commit is contained in:
@@ -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 = "/^<svg.+?width=\"{$defaultSize}\"/";
|
||||
@@ -131,7 +134,7 @@ class IconExtensionTest extends TestCase
|
||||
|
||||
public function testDefaultSizeIsOnlySetOnce(): void
|
||||
{
|
||||
$defaultSize = IconExtension::DEFAULT_SIZE;
|
||||
$defaultSize = IconRuntime::DEFAULT_SIZE;
|
||||
$content = $this->icon->renderIcon(['icon' => self::ICON]);
|
||||
|
||||
$widthRegex = "/width=\"{$defaultSize}\"/";
|
||||
Reference in New Issue
Block a user