Repository: rmrevin/yii2-fontawesome
Branch: master
Commit: 4a1c6b60773f
Files: 33
Total size: 100.1 KB
Directory structure:
gitextract__3qv48g6/
├── .gitignore
├── .scrutinizer.yml
├── .travis.yml
├── AssetBundle.php
├── CHANGELOG.md
├── CdnFreeAssetBundle.php
├── CdnProAssetBundle.php
├── FA.php
├── FAB.php
├── FAL.php
├── FAR.php
├── FAS.php
├── FontAwesome.php
├── LICENSE
├── NpmFreeAssetBundle.php
├── NpmProAssetBundle.php
├── README.md
├── bin/
│ ├── .gitignore
│ └── convertNames.sh
├── cdn/
│ └── AssetBundle.php
├── component/
│ ├── Icon.php
│ ├── Stack.php
│ └── UnorderedList.php
├── composer.json
├── phpunit.xml.dist
└── tests/
└── unit/
├── .gitignore
├── TestCase.php
├── bootstrap.php
├── config/
│ ├── .gitignore
│ └── main.php
├── fontawesome/
│ └── MainTest.php
└── runtime/
├── .gitignore
└── assets/
└── .gitignore
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/.idea
/vendor
/coverage
/node_modules
/package.json
/package.lock
/yarn.lock
================================================
FILE: .scrutinizer.yml
================================================
build:
environment:
php:
version: 7.1
dependencies:
before:
- composer global require "fxp/composer-asset-plugin:~1.1"
tests:
override:
- phpunit
imports:
- php
checks:
php:
code_rating: true
duplication: true
tools:
php_sim: false
php_cpd: false
php_pdepend: true
php_analyzer: true
php_changetracking: true
external_code_coverage:
timeout: 2100 # Timeout in seconds.
filter:
excluded_paths:
- tests/*
- vendor/*
================================================
FILE: .travis.yml
================================================
dist: trusty
language: php
php:
- 7.1
- 7.2
- 7.3
matrix:
fast_finish: true
sudo: false
cache:
directories:
- vendor
install:
- travis_retry composer self-update && composer --version
- travis_retry composer global require "fxp/composer-asset-plugin:~1.1"
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- travis_retry composer install --prefer-dist --no-interaction
script:
- ./vendor/bin/phpunit --verbose --coverage-clover=coverage/coverage.clover
after_script:
- travis_retry wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage/coverage.clover
================================================
FILE: AssetBundle.php
================================================
fixed_width()` is deprecated. Use instead `icon()->fixedWidth()`.
* Method `icon()->pull_left()` is deprecated. Use instead `icon()->pullLeft()`.
* Method `icon()->pull_right()` is deprecated. Use instead `icon()->pullRight()`.
* Updated tests.
2015-04-08 - 2.9.1
------------------
* Fix asset bundle publish bug on windows.
2015-03-31 - 2.9.0
------------------
* In asset bundle added `init` method for filtering publising assets.
2015-03-17 - 2.8.2
------------------
* Refactoring.
2015-03-16 - 2.8.1
------------------
* Update readme.
2015-03-16 - 2.8.0
------------------
* In class `FA` add static property `cssPrefix` for customizing css class.
* Refactoring.
* Update readme.
2015-02-08 - 2.7.1
------------------
* Update travisCI config.
2015-01-26 - 2.7.0
------------------
* `Font Awesome` updated to version `4.3`.
* Update icons constants list.
* Update readme.
Until 2015-03-04
----------------
* Implementation of extension.
================================================
FILE: CdnFreeAssetBundle.php
================================================
[
'css/*',
'js/*',
'webfonts/*',
'sprites/*',
'svgs/*',
],
];
}
================================================
FILE: NpmProAssetBundle.php
================================================
[
'css/*',
'js/*',
'webfonts/*',
'sprites/*',
'svgs/*',
],
];
}
================================================
FILE: README.md
================================================
Yii 2 [Font Awesome](http://fortawesome.github.io/Font-Awesome/) Asset Bundle
===============================
This extension provides a assets bundle with [Font Awesome](https://fontawesome.com/)
for [Yii framework 2.0](http://www.yiiframework.com/) applications and helper to use icons.
For license information check the [LICENSE](https://github.com/rmrevin/yii2-fontawesome/blob/master/LICENSE)-file.
[](https://packagist.org/packages/rmrevin/yii2-fontawesome)
[](https://packagist.org/packages/rmrevin/yii2-fontawesome)
[](https://packagist.org/packages/rmrevin/yii2-fontawesome)
[](https://packagist.org/packages/rmrevin/yii2-fontawesome)
Code Status
-----------
[](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/?branch=master)
[](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/?branch=master)
[](https://travis-ci.org/rmrevin/yii2-fontawesome)
[](https://www.versioneye.com/user/projects/54119b799e16229fe00000da)
Support
-------
* [GutHub issues](https://github.com/rmrevin/yii2-fontawesome/issues)
* [Public chat](https://gitter.im/rmrevin/support)
Fontawesome version
-------------------
| Version of font-awesome | Version of extension |
| ---:|:--- |
| 4.* | ~2.17 |
| 5.* | ~3.0 |
Update to `3.2`
---------------
Be careful in version 3.2 `rmrevin\yii\fontawesome\AssetBundle` package use cdn by default. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/master/CHANGELOG.md).
Update to `3.0`
---------------
Be careful in version 3.0 deprecated methods were removed. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/master/CHANGELOG.md).
Update to `2.17`
----------------
Be careful in version 2.17 deprecated methods were removed. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/2.x/CHANGELOG.md).
Installation
------------
The preferred way to install this extension is through [composer](https://getcomposer.org/).
Either run
```bash
composer require "rmrevin/yii2-fontawesome:~3.5"
```
or add
```
"rmrevin/yii2-fontawesome": "~3.5",
```
to the `require` section of your `composer.json` file.
Usage with fa pro version
-------------------------
### CDN
Register your domain here - https://fontawesome.com/how-to-use/on-the-web/setup/getting-started
Add `CdnProAssetBundle` as depends of your app asset bundle:
```php
class AppAsset extends AssetBundle
{
// ...
public $depends = [
// ...
'rmrevin\yii\fontawesome\CdnProAssetBundle'
];
}
```
Or inject `CdnProAssetBundle` in your view:
```php
\rmrevin\yii\fontawesome\CdnProAssetBundle::register($this);
```
### NPM
Install npm package of font:
```
npm install @fortawesome/fontawesome-pro
```
or
```
yarn add @fortawesome/fontawesome-pro
```
And add `NpmProAssetBundle` as depends of your app asset bundle:
```php
class AppAsset extends AssetBundle
{
// ...
public $depends = [
// ...
'rmrevin\yii\fontawesome\NpmProAssetBundle'
];
}
```
Or inject `NpmProAssetBundle` in your view:
```php
rmrevin\yii\fontawesome\NpmProAssetBundle::register($this);
```
### Optional
In order for do not install the free version of the font-awesome package, you can add it to the `replace` section of `composer.json`.
```
"replace": {
"fortawesome/font-awesome": "*"
},
```
Usage with fa free version
-------------------------
### CDN
Add `CdnFreeAssetBundle` as depends of your app asset bundle:
```php
class AppAsset extends AssetBundle
{
// ...
public $depends = [
// ...
'rmrevin\yii\fontawesome\CdnFreeAssetBundle'
];
}
```
Or inject `CdnFreeAssetBundle` in your view:
```php
rmrevin\yii\fontawesome\CdnFreeAssetBundle::register($this);
```
# Composer
Free version of package `fortawesome/font-awesome` already installed in vendor.
Add `NpmFreeAssetBundle` as depends of your app asset bundle:
```php
class AppAsset extends AssetBundle
{
// ...
public $depends = [
// ...
'rmrevin\yii\fontawesome\NpmFreeAssetBundle'
];
}
```
Or inject `NpmFreeAssetBundle` in your view:
```php
rmrevin\yii\fontawesome\NpmFreeAssetBundle::register($this);
```
Class reference
---------------
Namespace: `rmrevin\yii\fontawesome`;
### Class `FAB`, `FAL`, `FAR`, `FAS` or `FontAwesome`
* `static FAR::icon($name, $options=[])` - Creates an [`component\Icon`](#class-componenticon) that can be used to FontAwesome html icon
* `$name` - name of icon in font awesome set.
* `$options` - additional attributes for `i.fa` html tag.
* `static FAR::stack($name, $options=[])` - Creates an [`component\Stack`](#class-componentstack) that can be used to FontAwesome html icon
* `$options` - additional attributes for `span.fa-stack` html tag.
### Class `component\Icon`
* `(string)$Icon` - render icon
* `$Icon->addCssClass($value)` - add to html tag css class in `$value`
* `$value` - name of css class
* `$Icon->inverse()` - add to html tag css class `fa-inverse`
* `$Icon->spin()` - add to html tag css class `fa-spin`
* `$Icon->fixedWidth()` - add to html tag css class `fa-fw`
* `$Icon->ul()` - add to html tag css class `fa-ul`
* `$Icon->li()` - add to html tag css class `fa-li`
* `$Icon->border()` - add to html tag css class `fa-border`
* `$Icon->pullLeft()` - add to html tag css class `pull-left`
* `$Icon->pullRight()` - add to html tag css class `pull-right`
* `$Icon->size($value)` - add to html tag css class with size
* `$value` - size value (variants: `FA::SIZE_LARGE`, `FA::SIZE_2X`, `FA::SIZE_3X`, `FA::SIZE_4X`, `FA::SIZE_5X`)
* `$Icon->rotate($value)` - add to html tag css class with rotate
* `$value` - rotate value (variants: `FA::ROTATE_90`, `FA::ROTATE_180`, `FA::ROTATE_270`)
* `$Icon->flip($value)` - add to html tag css class with rotate
* `$value` - flip value (variants: `FA::FLIP_HORIZONTAL`, `FA::FLIP_VERTICAL`)
### Class `component\Stack`
* `(string)$Stack` - render icon stack
* `$Stack->icon($icon, $options=[])` - set icon for stack
* `$icon` - name of icon or `component\Icon` object
* `$options` - additional attributes for icon html tag.
* `$Stack->icon($icon, $options=[])` - set background icon for stack
* `$icon` - name of icon or `component\Icon` object
* `$options` - additional attributes for icon html tag.
Helper examples
---------------
```php
use rmrevin\yii\fontawesome\FAS;
// or (only in pro version https://fontawesome.com/pro)
// use rmrevin\yii\fontawesome\FAR;
// use rmrevin\yii\fontawesome\FAL;
// use rmrevin\yii\fontawesome\FAB;
// normal use
echo FAS::icon('home'); //
// shortcut
echo FAS::i('home'); //
// icon with additional attributes
echo FAS::icon(
'arrow-left',
['class' => 'big', 'data-role' => 'arrow']
); //
// icon in button
echo Html::submitButton(
Yii::t('app', '{icon} Save', ['icon' => FAS::icon('check')])
); //
// icon with additional methods
echo FAS::icon('cog')->inverse(); //
echo FAS::icon('cog')->spin(); //
echo FAS::icon('cog')->fixedWidth(); //
echo FAS::icon('cog')->li(); //
echo FAS::icon('cog')->border(); //
echo FAS::icon('cog')->pullLeft(); //
echo FAS::icon('cog')->pullRight(); //
// icon size
echo FAS::icon('cog')->size(FAS::SIZE_3X);
// values: FAS::SIZE_LARGE, FAS::SIZE_2X, FAS::SIZE_3X, FAS::SIZE_4X, FAS::SIZE_5X
//
// icon rotate
echo FAS::icon('cog')->rotate(FAS::ROTATE_90);
// values: FAS::ROTATE_90, FAS::ROTATE_180, FAS::ROTATE_180
//
// icon flip
echo FAS::icon('cog')->flip(FAS::FLIP_VERTICAL);
// values: FAS::FLIP_HORIZONTAL, FAS::FLIP_VERTICAL
//
// icon with multiple methods
echo FAS::icon('cog')
->spin()
->fixedWidth()
->pullLeft()
->size(FAS::SIZE_LARGE);
//
// icons stack
echo FAS::stack()
->icon('twitter')
->on('square-o');
//
//
//
//
// icons stack with additional attributes
echo FAS::stack(['data-role' => 'stacked-icon'])
->on(FAS::Icon('square')->inverse())
->icon(FAS::Icon('cog')->spin());
//
//
//
//
// Stacking text and icons
echo FAS::stack()
->on(FAS::Icon('square'))
->text('1');
//
//
// 1
//
// Stacking text and icons with options
echo FAS::stack()
->on(FAS::Icon('square'))
->text('1', ['tag'=>'strong', 'class'=>'stacked-text']);
//
//
// 1
//
// Now you can add some css for vertical text positioning:
.stacked-text { margin-top: .3em; }
// unordered list icons
echo FAS::ul(['data-role' => 'unordered-list'])
->item('Bullet item', ['icon' => 'circle'])
->item('Checked item', ['icon' => 'check']);
//
// - Bullet item
// - Checked Item
//
// autocomplete icons name in IDE
echo FAS::icon(FAS::_COG);
echo FAS::icon(FAS::_DESKTOP);
echo FAS::stack()
->on(FAS::_CIRCLE_O)
->icon(FAS::_TWITTER);
```
================================================
FILE: bin/.gitignore
================================================
result.txt
================================================
FILE: bin/convertNames.sh
================================================
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
VARIABLES_PATH="${DIR}/../vendor/fortawesome/font-awesome/scss/_variables.scss"
RESULT_PATH="${DIR}/result.txt"
echo '' > "${RESULT_PATH}"
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ ${line} =~ fa\-var\-([a-z0-9\-]+): ]]
then
iconName=${BASH_REMATCH[1]}
upperIconName=`echo ${iconName} | tr /a-z/ /A-Z/`
upperIconName=$(echo ${upperIconName} | sed 's/-/_/g')
echo "const _${upperIconName} = '${iconName}';" >> "${RESULT_PATH}"
fi
done < "${VARIABLES_PATH}"
echo "Done. See result in ${RESULT_PATH}";
================================================
FILE: cdn/AssetBundle.php
================================================
options = $options;
}
/**
* @return string
*/
public function __toString()
{
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'i');
return Html::tag($tag, null, $options);
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function inverse()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-inverse');
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function spin()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-spin');
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function pulse()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-pulse');
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function fixedWidth()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-fw');
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function li()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-li');
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function border()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-border');
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function pullLeft()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-pull-left');
}
/**
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function pullRight()
{
return $this->addCssClass(FontAwesome::$basePrefix . '-pull-right');
}
/**
* @param string $value
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function size($value)
{
$values = [
FontAwesome::SIZE_LG,
FontAwesome::SIZE_SM,
FontAwesome::SIZE_XS,
FontAwesome::SIZE_2X,
FontAwesome::SIZE_3X,
FontAwesome::SIZE_4X,
FontAwesome::SIZE_5X,
FontAwesome::SIZE_6X,
FontAwesome::SIZE_7X,
FontAwesome::SIZE_8X,
FontAwesome::SIZE_9X,
FontAwesome::SIZE_10X,
];
return $this->addCssClass(
FontAwesome::$basePrefix . '-' . $value,
in_array((string)$value, $values, true),
sprintf(
'%s - invalid value. Use one of the constants: %s.',
'FontAwesome::size()',
implode(', ', $values)
)
);
}
/**
* @param string $value
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function rotate($value)
{
$values = [FontAwesome::ROTATE_90, FontAwesome::ROTATE_180, FontAwesome::ROTATE_270];
return $this->addCssClass(
FontAwesome::$basePrefix . '-rotate-' . $value,
in_array((string)$value, $values, true),
sprintf(
'%s - invalid value. Use one of the constants: %s.',
'FontAwesome::rotate()',
implode(', ', $values)
)
);
}
/**
* @param string $value
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
*/
public function flip($value)
{
$values = [FontAwesome::FLIP_HORIZONTAL, FontAwesome::FLIP_VERTICAL];
return $this->addCssClass(
FontAwesome::$basePrefix . '-flip-' . $value,
in_array((string)$value, [FontAwesome::FLIP_HORIZONTAL, FontAwesome::FLIP_VERTICAL], true),
sprintf(
'%s - invalid value. Use one of the constants: %s.',
'FontAwesome::flip()',
implode(', ', $values)
)
);
}
/**
* @param string $class
* @param bool $condition
* @param string|bool $throw
* @return \rmrevin\yii\fontawesome\component\Icon
* @throws \yii\base\InvalidConfigException
* @codeCoverageIgnore
*/
public function addCssClass($class, $condition = true, $throw = false)
{
if ($condition === false) {
if (!empty($throw)) {
$message = !is_string($throw)
? 'Condition is false'
: $throw;
throw new InvalidConfigException($message);
}
} else {
Html::addCssClass($this->options, $class);
}
return $this;
}
}
================================================
FILE: component/Stack.php
================================================
iconCssPrefix = $iconCssPrefix;
Html::addCssClass($options, FontAwesome::$basePrefix . '-stack');
$this->options = $options;
}
/**
* @return string
* @throws \yii\base\InvalidConfigException
*/
public function __toString()
{
$options = $this->options;
$tag = ArrayHelper::remove($options, 'tag', 'span');
$template = ArrayHelper::remove($options, 'template', '{back}{front}');
$iconBack = $this->icon_back instanceof Icon
? $this->icon_back->addCssClass(FontAwesome::$basePrefix . '-stack-2x')
: null;
if ($this->text_front !== null) {
$contentFront = $this->text_front;
} else {
$contentFront = $this->icon_front instanceof Icon
? $this->icon_front->addCssClass(FontAwesome::$basePrefix . '-stack-1x')
: null;
}
$content = str_replace(['{back}', '{front}'], [$iconBack, $contentFront], $template);
return Html::tag($tag, $content, $options);
}
/**
* @param string|Icon $icon
* @param array $options
* @return \rmrevin\yii\fontawesome\component\Stack
*/
public function icon($icon, $options = [])
{
if (is_string($icon)) {
$icon = new Icon($this->iconCssPrefix, $icon, $options);
}
$this->icon_front = $icon;
return $this;
}
/**
* @param string $text
* @param array $options
* @return \rmrevin\yii\fontawesome\component\Stack
*/
public function text($text = '', $options = [])
{
$tag = ArrayHelper::remove($options, 'tag', 'span');
Html::addCssClass($options, FontAwesome::$basePrefix . '-stack-1x');
$this->text_front = Html::tag($tag, $text, $options);
return $this;
}
/**
* @param string|Icon $icon
* @param array $options
* @return \rmrevin\yii\fontawesome\component\Stack
*/
public function on($icon, $options = [])
{
if (is_string($icon)) {
$icon = new Icon($this->iconCssPrefix, $icon, $options);
}
$this->icon_back = $icon;
return $this;
}
}
================================================
FILE: component/UnorderedList.php
================================================
iconCssPrefix = $iconCssPrefix;
Html::addCssClass($options, FontAwesome::$basePrefix . '-ul');
$options['item'] = function ($item, $index) {
return call_user_func($item, $index);
};
$this->options = $options;
}
/**
* @return string
*/
public function __toString()
{
return Html::ul($this->items, $this->options);
}
/**
* @param string $label
* @param array $options
* @return \rmrevin\yii\fontawesome\component\UnorderedList
*/
public function item($label, $options = [])
{
$this->items[] = function ($index) use ($label, $options) {
$tag = ArrayHelper::remove($options, 'tag', 'li');
$icon = ArrayHelper::remove($options, 'icon');
$icon = empty($icon)
? null
: (is_string($icon) ? (string)(new Icon($this->iconCssPrefix, $icon))->li() : $icon);
$content = trim($icon . $label);
return Html::tag($tag, $content, $options);
};
return $this;
}
}
================================================
FILE: composer.json
================================================
{
"name": "rmrevin/yii2-fontawesome",
"description": "Asset Bundle for Yii2 with Font Awesome",
"keywords": [
"yii",
"font",
"awesome",
"asset",
"bundle"
],
"type": "yii2-extension",
"license": "MIT",
"minimum-stability": "stable",
"support": {
"issues": "https://github.com/rmrevin/yii2-fontawesome/issues",
"source": "https://github.com/rmrevin/yii2-fontawesome"
},
"authors": [
{
"name": "Revin Roman",
"email": "roman@rmrevin.com",
"homepage": "https://rmrevin.com/"
}
],
"require": {
"php": ">=5.4.0",
"fortawesome/font-awesome": "^5.15.0",
"yiisoft/yii2": "^2.0.0"
},
"require-dev": {
"doctrine/instantiator": "1.0.*",
"phpdocumentor/reflection-docblock": "~3.1.0",
"phpunit/phpunit": "^6.0"
},
"autoload": {
"psr-4": {
"rmrevin\\yii\\fontawesome\\": ""
}
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
}
================================================
FILE: phpunit.xml.dist
================================================
./
./tests
./vendor
./tests/unit/fontawesome
================================================
FILE: tests/unit/.gitignore
================================================
runtime/cache/*
================================================
FILE: tests/unit/TestCase.php
================================================
mock_application();
}
/**
* Populates Yii::$app with a new application
* The application will be destroyed on tearDown() automatically.
* @param string $appClass
*/
protected function mock_application($appClass = '\yii\console\Application')
{
// for update self::$params
$this->get_param('id');
/** @var \yii\console\Application $app */
new $appClass(self::$params);
}
/**
* Returns a test configuration param from /data/config.php
* @param string $name params name
* @param mixed $default default value to use when param is not set.
* @return mixed the value of the configuration param
*/
public function get_param($name, $default = null)
{
if (self::$params === null) {
self::$params = require(__DIR__ . '/config/main.php');
$main_local = __DIR__ . '/config/main-local.php';
if (file_exists($main_local)) {
self::$params = ArrayHelper::merge(self::$params, require($main_local));
}
}
return isset(self::$params[$name]) ? self::$params[$name] : $default;
}
protected function tearDown()
{
parent::tearDown();
}
/**
* Destroys application in Yii::$app by setting it to null.
*/
protected function destroy_application()
{
\Yii::$app = null;
}
}
================================================
FILE: tests/unit/bootstrap.php
================================================
'testapp',
'basePath' => $baseDir,
'aliases' => [
'@web' => '/',
'@webroot' => $baseDir . '/runtime',
'@vendor' => realpath($baseDir . '/../../vendor'),
'@bower' => realpath($baseDir . '/../../vendor/bower'),
]
];
================================================
FILE: tests/unit/fontawesome/MainTest.php
================================================
assertInstanceOf('rmrevin\yii\fontawesome\FAR', new FAR());
$this->assertInstanceOf('rmrevin\yii\fontawesome\FontAwesome', new FAR());
$this->assertInstanceOf('rmrevin\yii\fontawesome\FontAwesome', new FontAwesome());
$Icon = FAR::icon('cog');
$this->assertInstanceOf('rmrevin\yii\fontawesome\component\Icon', $Icon);
$Stack = FAR::stack();
$this->assertInstanceOf('rmrevin\yii\fontawesome\component\Stack', $Stack);
}
public function testStackOutput()
{
$this->assertEquals(
(string)FAR::s(),
''
);
$this->assertEquals(
(string)FAR::stack(),
''
);
$this->assertEquals(
(string)FAR::stack(['tag' => 'div']),
''
);
$this->assertEquals(
(string)FAR::stack()
->icon('cog'),
''
);
$this->assertEquals(
(string)FAR::stack()
->on('square-o'),
''
);
$this->assertEquals(
(string)FAR::stack()
->icon('cog')
->on('square-o'),
''
);
$this->assertEquals(
(string)FAR::stack(['data-role' => 'stack'])
->icon('cog', ['data-role' => 'icon',])
->on('square-o', ['data-role' => 'background']),
''
);
$this->assertEquals(
(string)FAR::stack()
->icon(FAR::icon('cog')->spin())
->on(FAR::icon('square-o')->size(FAR::SIZE_3X)),
''
);
$this->assertEquals(
(string)FAR::stack()
->icon(FAR::Icon('cog')->spin())
->on(FAR::Icon('square-o')->size(FAR::SIZE_3X)),
''
);
$this->assertNotEquals(
(string)FAR::stack()
->icon((string)FAR::Icon('cog')->spin())
->on((string)FAR::Icon('square-o')->size(FAR::SIZE_3X)),
''
);
$this->assertEquals(
(string)FAR::stack()
->text('hot')
->on('square-o'),
'hot'
);
}
public function testUlOutput()
{
$this->assertEquals(
(string)FAR::ul(),
''
);
$this->assertEquals(
(string)FAR::ul()
->item('Gear'),
""
);
$this->assertEquals(
(string)FAR::ul()
->item('Gear', ['icon' => 'cog']),
""
);
$this->assertEquals(
(string)FAR::ul()
->item('Check', ['icon' => 'check'])
->item('Gear', ['icon' => 'cog']),
""
);
$this->assertEquals(
(string)FAR::ul(['tag' => 'ol'])
->item('Check', ['icon' => 'check'])
->item('Gear', ['icon' => 'cog']),
"\n- Check
\n- Gear
\n
"
);
$this->assertEquals(
(string)FAR::ul()
->item('Check', ['icon' => 'check', 'class' => 'another-class']),
""
);
}
public function testAnotherPrefix()
{
FontAwesome::$basePrefix = 'fontawesome';
$this->assertEquals((string)FAR::icon('cog'), '');
$this->assertEquals((string)FAR::icon('cog', ['tag' => 'span']), '');
$this->assertEquals((string)FAR::icon('cog')->addCssClass('highlight'), '');
$this->assertEquals(
(string)FAR::stack()
->icon(FAR::Icon('cog')->spin())
->on(FAR::Icon('square-o')->size(FAR::SIZE_3X)),
''
);
$this->assertEquals(
(string)FAR::ul()
->item('Gear', ['icon' => 'cog']),
""
);
FontAwesome::$basePrefix = 'fa';
}
public function testIconOutput()
{
$this->assertEquals(FAR::i('cog'), '');
$this->assertEquals(FAR::icon('cog'), '');
$this->assertEquals(FAR::icon('cog', ['tag' => 'span']), '');
$this->assertEquals(FAR::icon('cog')->addCssClass('highlight'), '');
$this->assertEquals(FAR::icon('cog')->inverse(), '');
$this->assertEquals(FAR::icon('cog')->spin(), '');
$this->assertEquals(FAR::icon('cog')->pulse(), '');
$this->assertEquals(FAR::icon('cog')->fixedWidth(), '');
$this->assertEquals(FAR::icon('cog')->li(), '');
$this->assertEquals(FAR::icon('cog')->border(), '');
$this->assertEquals(FAR::icon('cog')->pullLeft(), '');
$this->assertEquals(FAR::icon('cog')->pullRight(), '');
$this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_2X), '');
$this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_3X), '');
$this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_4X), '');
$this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_5X), '');
$this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_LARGE), '');
$this->assertEquals(FAR::icon('cog')->rotate(FAR::ROTATE_90), '');
$this->assertEquals(FAR::icon('cog')->rotate(FAR::ROTATE_180), '');
$this->assertEquals(FAR::icon('cog')->rotate(FAR::ROTATE_270), '');
$this->assertEquals(FAR::icon('cog')->flip(FAR::FLIP_HORIZONTAL), '');
$this->assertEquals(FAR::icon('cog')->flip(FAR::FLIP_VERTICAL), '');
}
public function testIconSizeException()
{
$this->expectExceptionMessage(
'FontAwesome::size() - invalid value. Use one of the constants: lg, sm, xs, 2x, 3x, 4x, 5x, 6x, 7x, 8x, 9x, 10x.'
);
FAR::icon('cog')->size('badvalue');
}
public function testIconRotateException()
{
$this->expectExceptionMessage(
'FontAwesome::rotate() - invalid value. Use one of the constants: 90, 180, 270.'
);
FAR::icon('cog')->rotate('badvalue');
}
public function testIconFlipException()
{
$this->expectExceptionMessage(
'FontAwesome::flip() - invalid value. Use one of the constants: horizontal, vertical.'
);
FAR::icon('cog')->flip('badvalue');
}
public function testIconAddCssClassCondition()
{
$this->assertEquals(FAR::$cssPrefix, 'far');
$this->assertEquals((string)FAR::icon('cog')->addCssClass('highlight', true), '');
$this->expectExceptionMessage('Condition is false');
FAR::icon('cog')->addCssClass('highlight', false, true);
}
}
================================================
FILE: tests/unit/runtime/.gitignore
================================================
*
!.gitignore
!assets
================================================
FILE: tests/unit/runtime/assets/.gitignore
================================================
*
!.gitignore