function IconPackManagerKernelTest::testProcessDefinition
Test the IconPackManager::processDefinition method.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Theme/ Icon/ IconPackManagerKernelTest.php, line 298
Class
- IconPackManagerKernelTest
- @coversDefaultClass \Drupal\Core\Theme\Icon\Plugin\IconPackManager
Namespace
Drupal\KernelTests\Core\Theme\IconCode
public function testProcessDefinition() : void {
$relative_path = 'core/modules/system/tests/modules/icon_test';
$definition = [
'id' => 'foo',
'label' => 'Foo',
'provider' => 'icon_test',
'extractor' => 'test',
];
$this->pluginManagerIconPack
->processDefinition($definition, 'foo');
$this->assertSame('foo', $definition['id']);
$this->assertSame('Foo', $definition['label']);
$this->assertEquals($relative_path, $definition['relative_path']);
$absolute_path = sprintf('%s/%s', $this->appRoot, $relative_path);
$this->assertEquals($absolute_path, $definition['absolute_path']);
$this->assertArrayHasKey('icons', $definition);
$this->assertEmpty($definition['icons']);
$definition = [
'id' => 'foo',
'provider' => 'icon_test',
'extractor' => 'test_finder',
'template' => '{{ icon_id }}',
'config' => [
'sources' => [
'icons/flat/*.svg',
],
],
];
$this->pluginManagerIconPack
->processDefinition($definition, 'foo');
$this->assertArrayHasKey('icons', $definition);
$this->assertNotEmpty($definition['icons']);
$this->assertCount(5, $definition['icons']);
foreach ($definition['icons'] as $icon) {
$this->assertInstanceOf(IconDefinitionInterface::class, $icon);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.