Skip to content

Commit

Permalink
fix extension and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcw committed Apr 10, 2021
1 parent bb87a02 commit 34166ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Twig/HeroiconsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace MarcW\Heroicons\Twig;

use MarcW\Heroicons\Heroicons;
use Twig\TwigFunction;
use Twig\Extension\AbstractExtension;

class HeroiconsExtension extends AbstractExtension
Expand Down
15 changes: 14 additions & 1 deletion tests/Twig/HeroiconsExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace MarcW\Heroicons\Tests\Twig;

use PHPUnit\Framework\TestCase;
use MarcW\Heroicons\Twig\HeroiconsExtension;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Loader\ArrayLoader;

class HeroiconsExtensionTest extends TestCase
{
Expand All @@ -22,4 +24,15 @@ public function testGetHeroiconWithCustomClass()

$this->assertSame(0, strpos($svg, '<svg class="foo bar" xmlns'));
}

public function testExtensionIsRegistered()
{
$twig = new Environment(new ArrayLoader());
$twig->addExtension(new HeroiconsExtension());

$template = $twig->createTemplate('{{ heroicon("academic-cap") }}', 'test');
$output = $template->render();

$this->assertSame(0, strpos($output, '<svg xmlns'));
}
}

0 comments on commit 34166ec

Please sign in to comment.