*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
class IconClassTest extends \Codeception\Test\Unit
{
private $memo_assets_url;
public function setUp(): void
{
$this->memo_assets_url = Assets::url();
Assets::set_assets_url('');
}
public function tearDown(): void
{
Assets::set_assets_url($this->memo_assets_url);
}
public function testIconCreateAsImg()
{
$this->assertEquals(
'',
Icon::create('vote')->asImg()
);
}
public function testIconCreateAsImgWithAddition()
{
$this->assertEquals(
'',
Icon::create('vote')->asImg()
);
}
public function testIconCreateAsImgWithSize()
{
$this->assertEquals(
'',
Icon::create('vote')->asImg(100)
);
}
public function testIconCreateAsImgWithTitle()
{
$this->assertEquals(
'',
Icon::create('vote')->asImg(24, ['title' => 'Mit Anhang'])
);
}
public function testIconCreateAsImgWithHspace()
{
$this->assertEquals(
'',
Icon::create('arr_2left')->asImg(['hspace' => 3])
);
}
public function testIconCreateAsImgWithClass()
{
$this->assertEquals(
'',
Icon::create('staple', Icon::ROLE_INFO)->asImg(24, ['class' => 'text-bottom'])
);
}
public function testIconCreateAsImgWithClassAndTitle()
{
$this->assertEquals(
'',
Icon::create('upload', Icon::ROLE_NEW, ['title' => 'Datei hochladen'])
->asImg(24, ['class' => 'text-bottom'])
);
}
public function testIconCreateAsInput()
{
$this->assertEquals(
'',
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(
'',
Icon::create('vote')->asImg(false)
);
}
public function testIconCreateAsInputWithoutSize()
{
$this->assertEquals(
'',
Icon::create('upload')->asInput(false)
);
}
public function testIconCreateRemovedExtras()
{
$this->assertEquals(
'',
Icon::create('add/vote')->asImg(false)
);
$this->assertEquals(
'',
Icon::create('vote+add')->asImg(false)
);
}
}