Pass in default options to runtime test

This commit is contained in:
2023-06-27 10:30:10 +01:00
parent 173c08b0d0
commit 03a1f033ee

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Pcm\IconBundle\Tests\Twig\Functions; namespace Pcm\IconBundle\Tests\Twig\Functions;
use Pcm\IconBundle\DependencyInjection\Configuration;
use Pcm\IconBundle\Exception\ColourNotFound; use Pcm\IconBundle\Exception\ColourNotFound;
use Pcm\IconBundle\Exception\IconNotFound; use Pcm\IconBundle\Exception\IconNotFound;
use Pcm\IconBundle\Twig\Runtime\IconRuntime; use Pcm\IconBundle\Twig\Runtime\IconRuntime;
@@ -37,6 +38,7 @@ class IconRuntimeTest extends TestCase
protected function setUp(): void protected function setUp(): void
{ {
$this->icon = new IconRuntime( $this->icon = new IconRuntime(
defaultOptions: ['size' => Configuration::DEFAULT_SIZE, 'colour' => Configuration::DEFAULT_COLOUR],
directories: ['tests/icons'], directories: ['tests/icons'],
colours: self::COLOURS colours: self::COLOURS
); );
@@ -122,7 +124,7 @@ class IconRuntimeTest extends TestCase
public function testDefaultSizeIsSetOnSvgIfNoSizeOptionPassed(): void public function testDefaultSizeIsSetOnSvgIfNoSizeOptionPassed(): void
{ {
$defaultSize = IconRuntime::DEFAULT_SIZE; $defaultSize = Configuration::DEFAULT_SIZE;
$content = $this->icon->renderIcon(['icon' => self::ICON]); $content = $this->icon->renderIcon(['icon' => self::ICON]);
$regex = "/^<svg.+?width=\"{$defaultSize}\"/"; $regex = "/^<svg.+?width=\"{$defaultSize}\"/";
@@ -134,7 +136,7 @@ class IconRuntimeTest extends TestCase
public function testDefaultSizeIsOnlySetOnce(): void public function testDefaultSizeIsOnlySetOnce(): void
{ {
$defaultSize = IconRuntime::DEFAULT_SIZE; $defaultSize = Configuration::DEFAULT_SIZE;
$content = $this->icon->renderIcon(['icon' => self::ICON]); $content = $this->icon->renderIcon(['icon' => self::ICON]);
$widthRegex = "/width=\"{$defaultSize}\"/"; $widthRegex = "/width=\"{$defaultSize}\"/";