function IconTest::testPreRenderIconNoIcon

Test the Icon::preRenderIcon method.

File

core/tests/Drupal/Tests/Core/Theme/Icon/IconTest.php, line 240

Class

IconTest
@coversDefaultClass \Drupal\Core\Render\Element\Icon

Namespace

Drupal\Tests\Core\Theme\Icon

Code

public function testPreRenderIconNoIcon() : void {
    $prophecy = $this->prophesize(IconPackManagerInterface::class);
    $prophecy->getIcon('foo:bar')
        ->willReturn(NULL);
    $pluginManagerIconPack = $prophecy->reveal();
    $this->container
        ->set('plugin.manager.icon_pack', $pluginManagerIconPack);
    $element = [
        '#type' => 'icon',
        '#pack_id' => 'foo',
        '#icon_id' => 'bar',
    ];
    $actual = Icon::preRenderIcon($element);
    $this->assertEquals($element, $actual);
}

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