Skip to content
This repository was archived by the owner on Jul 7, 2025. It is now read-only.

Commit 7302f02

Browse files
author
Nate Wiebe
committed
Add function to test attribute setting
1 parent d3fa016 commit 7302f02

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/IconTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,28 @@ public function testAltText(): void
8686
$this->assertXmlStringEqualsXmlString($iconString, $this->changeSvgTitleId($this->icon->render(), $iconTitleId));
8787
}
8888

89+
public function testSettingAttributes(): void
90+
{
91+
$attributes = [
92+
'data-custom-attribute' => 'test',
93+
'data-other-attribute' => 'test2',
94+
'width' => 12,
95+
'height' => 24,
96+
'stroke' => '#fff',
97+
'stroke-width' => 2,
98+
'class' => 'custom-class'
99+
];
100+
101+
$this->icon->setAttributes(['data-custom-attribute' => $attributes['data-custom-attribute']])
102+
->setAttribute('data-other-attribute', $attributes['data-other-attribute'])
103+
->setSize($attributes['width'], $attributes['height'])
104+
->setColor($attributes['stroke'])
105+
->setWeight($attributes['stroke-width'])
106+
->setCssClass($attributes['class']);
107+
108+
$this->assertEquals($attributes, $this->icon->getAttributes());
109+
}
110+
89111
private function changeSvgTitleId(string $svg, string $id): string
90112
{
91113
$xmlLoader = new Loader();

0 commit comments

Comments
 (0)