diff options
| author | Ron Lucke <lucke@elan-ev.de> | 2025-07-14 09:36:18 +0200 |
|---|---|---|
| committer | Ron Lucke <lucke@elan-ev.de> | 2025-07-14 09:36:18 +0200 |
| commit | 4355ded9bc56e0b06fbceffe61ddc37061cc3bc7 (patch) | |
| tree | 348493b6b0fd1286b86f213e5077413b97cf9747 /tests | |
| parent | 1e59dd2dacc51b3313d7780b66d4bf72e0484f86 (diff) | |
Color-Themes-System, fixes #5361
Closes #5361
Merge request studip/studip!4038
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/lib/classes/IconClassTest.php | 195 |
1 files changed, 43 insertions, 152 deletions
diff --git a/tests/unit/lib/classes/IconClassTest.php b/tests/unit/lib/classes/IconClassTest.php index 01a3a1b..bc7ad7f 100644 --- a/tests/unit/lib/classes/IconClassTest.php +++ b/tests/unit/lib/classes/IconClassTest.php @@ -23,156 +23,47 @@ class IconClassTest extends \Codeception\Test\Unit Assets::set_assets_url($this->memo_assets_url); } - public function testIconCreateAsImg() - { - $this->assertEquals( - '<img src="images/icons/blue/vote.svg" alt="" class="studip-icon icon-role-clickable icon-shape-vote">', - Icon::create('vote')->asImg() - ); - } - - public function testIconCreateAsImgWithAddition() - { - $this->assertEquals( - '<img src="images/icons/blue/vote.svg" alt="" class="studip-icon icon-role-clickable icon-shape-vote">', - Icon::create('vote')->asImg() - ); - } - - public function testIconCreateAsImgWithSize() - { - $this->assertEquals( - '<img style="width:100px;height:100px" src="images/icons/blue/vote.svg" alt="" class="studip-icon icon-role-clickable icon-shape-vote">', - Icon::create('vote')->asImg(100) - ); - } - - public function testIconCreateAsImgWithTitle() - { - $this->assertEquals( - '<img title="Mit Anhang" style="width:24px;height:24px" src="images/icons/blue/vote.svg" class="studip-icon icon-role-clickable icon-shape-vote">', - Icon::create('vote')->asImg(24, ['title' => 'Mit Anhang']) - ); - } - - public function testIconCreateAsImgWithHspace() - { - $this->assertEquals( - '<img hspace="3" src="images/icons/blue/arr_2left.svg" alt="" class="studip-icon icon-role-clickable icon-shape-arr_2left">', - Icon::create('arr_2left')->asImg(['hspace' => 3]) - ); - } - - public function testIconCreateAsImgWithClass() - { - $this->assertEquals( - '<img class="text-bottom studip-icon icon-role-info icon-shape-staple" style="width:24px;height:24px" src="images/icons/black/staple.svg" alt="">', - Icon::create('staple', Icon::ROLE_INFO)->asImg(24, ['class' => 'text-bottom']) - ); - } - - public function testIconCreateAsImgWithClassAndTitle() - { - $this->assertEquals( - '<img class="text-bottom studip-icon icon-role-new icon-shape-upload" title="Datei hochladen" style="width:24px;height:24px" src="images/icons/red/upload.svg">', - Icon::create('upload', Icon::ROLE_NEW, ['title' => 'Datei hochladen']) - ->asImg(24, ['class' => 'text-bottom']) - ); - } - - public function testIconCreateAsInput() - { - $this->assertEquals( - '<input type="image" class="text-bottom studip-icon icon-role-clickable icon-shape-upload" style="width:24px;height:24px" src="images/icons/blue/upload.svg" alt="">', - Icon::create('upload')->asInput(24, ['class' => 'text-bottom']) - ); - } - - public function testIconIsImmutable() - { - $icon = Icon::create('upload', attributes: ['title' => 'a title']); - $copy = $icon->copyWithRole(Icon::ROLE_CLICKABLE); - - $this->assertNotSame($icon, $copy); - } - - public function testIconCopyWithRole() - { - $icon = Icon::create('upload', attributes: ['title' => 'a title']); - $copy = $icon->copyWithRole(Icon::ROLE_INFO); - - $this->assertEquals($icon->getShape(), $copy->getShape()); - $this->assertNotEquals($icon->getRole(), $copy->getRole()); - $this->assertEquals($icon->getAttributes(), $copy->getAttributes()); - } - - public function testIconCopyWithShape() - { - $icon = Icon::create('upload', attributes: ['title' => 'a title']); - $copy = $icon->copyWithShape('staple'); - - $this->assertNotEquals($icon->getShape(), $copy->getShape()); - $this->assertEquals($icon->getRole(), $copy->getRole()); - $this->assertEquals($icon->getAttributes(), $copy->getAttributes()); - } - - public function testIconCopyWithAttributes() - { - $icon = Icon::create('upload', Icon::ROLE_CLICKABLE, ['title' => 'a title']); - $copy = $icon->copyWithAttributes(['title' => 'another title']); - - $this->assertEquals($icon->getShape(), $copy->getShape()); - $this->assertEquals($icon->getRole(), $copy->getRole()); - $this->assertNotEquals($icon->getAttributes(), $copy->getAttributes()); - } - - public function testStaticIcon() - { - $icon = Icon::create('https://i.imgur.com/kpTtTh.gif'); - $this->assertEquals($icon->asImagePath(), 'https://i.imgur.com/kpTtTh.gif'); - } - - public function testIconCreateAsCSSWithSize() - { - $this->assertEquals( - 'background-image:url(images/icons/blue/vote.svg);background-size:17px 17px;', - Icon::create('vote')->asCSS(17) - ); - } - - public function testIconCreateAsImagePath() - { - $this->assertEquals( - 'images/icons/blue/vote.svg', - Icon::create('vote')->asImagePath() - ); - } - - public function testIconCreateAsImgWithoutSize() - { - $this->assertEquals( - '<img src="images/icons/blue/vote.svg" alt="" class="studip-icon icon-role-clickable icon-shape-vote">', - Icon::create('vote')->asImg(false) - ); - } - - public function testIconCreateAsInputWithoutSize() - { - $this->assertEquals( - '<input type="image" src="images/icons/blue/upload.svg" alt="" class="studip-icon icon-role-clickable icon-shape-upload">', - Icon::create('upload')->asInput(false) - ); - } - - public function testIconCreateRemovedExtras() - { - $this->assertEquals( - '<img src="images/icons/blue/vote.svg" alt="" class="studip-icon icon-role-clickable icon-shape-vote">', - Icon::create('add/vote')->asImg(false) - ); - $this->assertEquals( - '<img src="images/icons/blue/vote.svg" alt="" class="studip-icon icon-role-clickable icon-shape-vote">', - Icon::create('vote+add')->asImg(false) - ); - } + public function testIconIsImmutable() + { + $icon = Icon::create('upload', attributes: ['title' => 'a title']); + $copy = $icon->copyWithRole(Icon::ROLE_CLICKABLE); + + $this->assertNotSame($icon, $copy); + } + + public function testIconCopyWithRole() + { + $icon = Icon::create('upload', attributes: ['title' => 'a title']); + $copy = $icon->copyWithRole(Icon::ROLE_INFO); + + $this->assertEquals($icon->getShape(), $copy->getShape()); + $this->assertNotEquals($icon->getRole(), $copy->getRole()); + $this->assertEquals($icon->getAttributes(), $copy->getAttributes()); + } + + public function testIconCopyWithShape() + { + $icon = Icon::create('upload', attributes: ['title' => 'a title']); + $copy = $icon->copyWithShape('staple'); + + $this->assertNotEquals($icon->getShape(), $copy->getShape()); + $this->assertEquals($icon->getRole(), $copy->getRole()); + $this->assertEquals($icon->getAttributes(), $copy->getAttributes()); + } + + public function testIconCopyWithAttributes() + { + $icon = Icon::create('upload', Icon::ROLE_CLICKABLE, ['title' => 'a title']); + $copy = $icon->copyWithAttributes(['title' => 'another title']); + + $this->assertEquals($icon->getShape(), $copy->getShape()); + $this->assertEquals($icon->getRole(), $copy->getRole()); + $this->assertNotEquals($icon->getAttributes(), $copy->getAttributes()); + } + + public function testStaticIcon() + { + $icon = Icon::create('https://i.imgur.com/kpTtTh.gif'); + $this->assertEquals($icon->asImagePath(), 'https://i.imgur.com/kpTtTh.gif'); + } } |
