assertInstanceOf('rmrevin\yii\fontawesome\FA', new FA());
$this->assertInstanceOf('rmrevin\yii\fontawesome\FontAwesome', new FA());
$this->assertInstanceOf('rmrevin\yii\fontawesome\FontAwesome', new FontAwesome());
$Icon = FA::icon('cog');
$this->assertInstanceOf('rmrevin\yii\fontawesome\component\Icon', $Icon);
$Stack = FA::stack();
$this->assertInstanceOf('rmrevin\yii\fontawesome\component\Stack', $Stack);
}
public function testStackOutput()
{
$this->assertEquals(
(string)FA::s(),
''
);
$this->assertEquals(
(string)FA::stack(),
''
);
$this->assertEquals(
(string)FA::stack()->tag('div'),
'
'
);
$this->assertEquals(
(string)FA::stack(['tag' => 'div']),
''
);
$this->assertEquals(
(string)FA::stack()
->icon('cog'),
''
);
$this->assertEquals(
(string)FA::stack()
->on('square-o'),
''
);
$this->assertEquals(
(string)FA::stack()
->icon('cog')
->on('square-o'),
''
);
$this->assertEquals(
(string)FA::stack(['data-role' => 'stack'])
->icon('cog', ['data-role' => 'icon',])
->on('square-o', ['data-role' => 'background']),
''
);
$this->assertEquals(
(string)FA::stack()
->icon((new Icon('cog'))->spin())
->on((new Icon('square-o'))->size(FA::SIZE_3X)),
''
);
$this->assertEquals(
(string)FA::stack()
->icon(FA::Icon('cog')->spin())
->on(FA::Icon('square-o')->size(FA::SIZE_3X)),
''
);
$this->assertNotEquals(
(string)FA::stack()
->icon((string)FA::Icon('cog')->spin())
->on((string)FA::Icon('square-o')->size(FA::SIZE_3X)),
''
);
}
public function testUlOutput()
{
$this->assertEquals(
(string)FA::ul(),
''
);
$this->assertEquals(
(string)FA::ul()
->item('Gear', ['icon' => 'cog']),
""
);
$this->assertEquals(
(string)FA::ul()
->item('Check', ['icon' => 'check'])
->item('Gear', ['icon' => 'cog']),
""
);
$this->assertEquals(
(string)FA::ul()
->tag('ol')
->item('Check', ['icon' => 'check'])
->item('Gear', ['icon' => 'cog']),
"\n- Check
\n- Gear
\n
"
);
$this->assertEquals(
(string)FA::ul(['tag' => 'ol'])
->item('Check', ['icon' => 'check'])
->item('Gear', ['icon' => 'cog']),
"\n- Check
\n- Gear
\n
"
);
$this->assertEquals(
(string)FA::ul()
->item('Check', ['icon' => 'check', 'class' => 'another-class']),
""
);
}
public function testAnotherPrefix()
{
$old_prefix = FA::$cssPrefix;
FA::$cssPrefix = 'fontawesome';
$this->assertEquals(FA::icon('cog'), '');
$this->assertEquals(FA::icon('cog')->tag('span'), '');
$this->assertEquals(FA::icon('cog', ['tag' => 'span']), '');
$this->assertEquals(FA::icon('cog')->addCssClass('highlight'), '');
$this->assertEquals(
(string)FA::stack()
->icon(FA::Icon('cog')->spin())
->on(FA::Icon('square-o')->size(FA::SIZE_3X)),
''
);
$this->assertEquals(
(string)FA::ul()
->item('Gear', ['icon' => 'cog']),
""
);
FA::$cssPrefix = $old_prefix;
}
public function testIconOutput()
{
$this->assertEquals(FA::i('cog'), '');
$this->assertEquals(FA::icon('cog'), '');
$this->assertEquals(FA::icon('cog')->tag('span'), '');
$this->assertEquals(FA::icon('cog', ['tag' => 'span']), '');
$this->assertEquals(FA::icon('cog')->addCssClass('highlight'), '');
$this->assertEquals(FA::icon('cog')->inverse(), '');
$this->assertEquals(FA::icon('cog')->spin(), '');
$this->assertEquals(FA::icon('cog')->fixedWidth(), '');
$this->assertEquals(FA::icon('cog')->li(), '');
$this->assertEquals(FA::icon('cog')->border(), '');
$this->assertEquals(FA::icon('cog')->pullLeft(), '');
$this->assertEquals(FA::icon('cog')->pullRight(), '');
$this->assertEquals(FA::icon('cog')->size(FA::SIZE_2X), '');
$this->assertEquals(FA::icon('cog')->size(FA::SIZE_3X), '');
$this->assertEquals(FA::icon('cog')->size(FA::SIZE_4X), '');
$this->assertEquals(FA::icon('cog')->size(FA::SIZE_5X), '');
$this->assertEquals(FA::icon('cog')->size(FA::SIZE_LARGE), '');
$this->assertEquals(FA::icon('cog')->rotate(FA::ROTATE_90), '');
$this->assertEquals(FA::icon('cog')->rotate(FA::ROTATE_180), '');
$this->assertEquals(FA::icon('cog')->rotate(FA::ROTATE_270), '');
$this->assertEquals(FA::icon('cog')->flip(FA::FLIP_HORIZONTAL), '');
$this->assertEquals(FA::icon('cog')->flip(FA::FLIP_VERTICAL), '');
}
public function testGetConstants()
{
$this->assertNotEmpty(FA::getConstants(false));
$this->assertNotEmpty(FA::getConstants(true));
}
public function testIconSizeException()
{
$this->setExpectedException(
'yii\base\InvalidConfigException',
'FA::size() - invalid value. Use one of the constants: FA::SIZE_LARGE, FA::SIZE_2X, FA::SIZE_3X, FA::SIZE_4X, FA::SIZE_5X.'
);
FA::icon('cog')->size('badvalue');
}
public function testIconRotateException()
{
$this->setExpectedException(
'yii\base\InvalidConfigException',
'FA::rotate() - invalid value. Use one of the constants: FA::ROTATE_90, FA::ROTATE_180, FA::ROTATE_270.'
);
FA::icon('cog')->rotate('badvalue');
}
public function testIconFlipException()
{
$this->setExpectedException(
'yii\base\InvalidConfigException',
'FA::flip() - invalid value. Use one of the constants: FA::FLIP_HORIZONTAL, FA::FLIP_VERTICAL.'
);
FA::icon('cog')->flip('badvalue');
}
public function testIconAddCssClassCondition()
{
$this->assertEquals(FA::$cssPrefix, 'fa');
$this->assertEquals(FA::icon('cog')->addCssClass('highlight', true), '');
$this->setExpectedException(
'yii\base\InvalidConfigException',
'Condition is false'
);
FA::icon('cog')->addCssClass('highlight', false, true);
}
}