function IconDefinitionTest::testCreateIcon
Test the IconDefinition::createIcon method.
@dataProvider providerCreateIcon
Parameters
array $data: The icon data.
File
-
core/
tests/ Drupal/ Tests/ Core/ Theme/ Icon/ IconDefinitionTest.php, line 106
Class
- IconDefinitionTest
- @coversDefaultClass \Drupal\Core\Theme\Icon\IconDefinition
Namespace
Drupal\Tests\Core\Theme\IconCode
public function testCreateIcon(array $data) : void {
$icon_data = $data['data'] ?? NULL;
if ($icon_data) {
$actual = IconDefinition::create($data['pack_id'], $data['icon_id'], $data['template'], $data['source'] ?? NULL, $data['group'] ?? NULL, $icon_data);
}
else {
$actual = IconDefinition::create($data['pack_id'], $data['icon_id'], $data['template'], $data['source'] ?? NULL, $data['group'] ?? NULL);
}
$icon_full_id = IconDefinition::createIconId($data['pack_id'], $data['icon_id']);
$this->assertEquals($icon_full_id, $actual->getId());
$this->assertEquals(IconDefinition::humanize($data['icon_id']), $actual->getLabel());
$this->assertEquals($data['icon_id'], $actual->getIconId());
$this->assertEquals($data['pack_id'], $actual->getPackId());
$this->assertEquals($data['template'], $actual->getTemplate());
if (isset($data['source'])) {
$this->assertEquals($data['source'], $actual->getSource());
}
if (isset($data['group'])) {
$this->assertEquals($data['group'], $actual->getGroup());
}
if ($icon_data) {
if (isset($icon_data['library'])) {
$this->assertEquals($icon_data['library'], $actual->getLibrary());
unset($icon_data['library']);
}
if (isset($icon_data['label'])) {
$this->assertSame($icon_data['label'], $actual->getPackLabel());
unset($icon_data['label']);
}
foreach ($icon_data as $key => $value) {
$this->assertEquals($icon_data[$key], $actual->getData($key));
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.