class IconsTwigExtensionTest

@coversDefaultClass \Drupal\Core\Template\IconsTwigExtension

@group icon

Hierarchy

Expanded class hierarchy of IconsTwigExtensionTest

File

core/tests/Drupal/Tests/Core/Theme/Icon/IconsTwigExtensionTest.php, line 15

Namespace

Drupal\Tests\Core\Theme\Icon
View source
class IconsTwigExtensionTest extends TestCase {
    
    /**
     * The twig extension.
     *
     * @var \Drupal\Core\Template\IconsTwigExtension
     */
    private IconsTwigExtension $iconsTwigExtension;
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        $this->iconsTwigExtension = new IconsTwigExtension();
    }
    
    /**
     * Test the IconsTwigExtension::getFunctions method.
     */
    public function testGetFunctions() : void {
        $functions = $this->iconsTwigExtension
            ->getFunctions();
        $this->assertCount(1, $functions);
        $this->assertEquals('icon', $functions[0]->getName());
    }
    
    /**
     * Test the IconsTwigExtension::getIconRenderable method.
     */
    public function testGetIconRenderable() : void {
        $settings = [
            'foo' => 'bar',
        ];
        $result = $this->iconsTwigExtension
            ->getIconRenderable('pack_id', 'icon_id', $settings);
        $expected = [
            '#type' => 'icon',
            '#pack_id' => 'pack_id',
            '#icon_id' => 'icon_id',
            '#settings' => $settings,
        ];
        $this->assertEquals($expected, $result);
    }

}

Members

Title Sort descending Modifiers Object type Summary
IconsTwigExtensionTest::$iconsTwigExtension private property The twig extension.
IconsTwigExtensionTest::setUp protected function
IconsTwigExtensionTest::testGetFunctions public function Test the IconsTwigExtension::getFunctions method.
IconsTwigExtensionTest::testGetIconRenderable public function Test the IconsTwigExtension::getIconRenderable method.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.