function SvgExtractorTest::testLoadIconSvgInvalid

Test the SvgExtractor::loadIcon() method with invalid svg.

File

core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php, line 309

Class

SvgExtractorTest
@coversDefaultClass \Drupal\Core\Theme\Plugin\IconExtractor\SvgExtractor

Namespace

Drupal\Tests\Core\Theme\Icon\Plugin

Code

public function testLoadIconSvgInvalid() : void {
    $icon = [
        'icon_id' => 'foo',
        'source' => '/path/source/foo.svg',
    ];
    $this->iconFinder
        ->method('getFileContents')
        ->with($icon['source'])
        ->willReturn('Not valid svg');
    $icon_loaded = $this->svgExtractorPlugin
        ->loadIcon($icon);
    $this->assertNull($icon_loaded);
    foreach (libxml_get_errors() as $error) {
        $this->assertSame("Start tag expected, '<' not found", trim($error->message));
    }
}

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