Blame view

vendor/rmrevin/yii2-fontawesome/tests/unit/fontawesome/MainTest.php 7.57 KB
e9aa73b0   andryeyev   + adminLte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  <?php
  /**
   * MainTest.php
   * @author Revin Roman
   * @link https://rmrevin.ru
   */
  
  namespace rmrevin\yii\fontawesome\tests\unit\fontawesome;
  
  use rmrevin\yii\fontawesome\component\Icon;
  use rmrevin\yii\fontawesome\FA;
  use rmrevin\yii\fontawesome\FontAwesome;
  
  /**
   * Class MainTest
   * @package rmrevin\yii\fontawesome\tests\unit\fontawesome
   */
  class MainTest extends \rmrevin\yii\fontawesome\tests\unit\TestCase
  {
  
      public function testMain()
      {
          $this->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::stack(),
              '<span class="fa-stack"></span>'
          );
  
          $this->assertEquals(
              (string)FA::stack()->tag('div'),
              '<div class="fa-stack"></div>'
          );
  
          $this->assertEquals(
              (string)FA::stack()
                  ->icon('cog'),
              '<span class="fa-stack"><i class="fa fa-cog fa-stack-1x"></i></span>'
          );
  
          $this->assertEquals(
              (string)FA::stack()
                  ->on('square-o'),
              '<span class="fa-stack"><i class="fa fa-square-o fa-stack-2x"></i></span>'
          );
  
          $this->assertEquals(
              (string)FA::stack()
                  ->icon('cog')
                  ->on('square-o'),
              '<span class="fa-stack"><i class="fa fa-square-o fa-stack-2x"></i><i class="fa fa-cog fa-stack-1x"></i></span>'
          );
  
          $this->assertEquals(
              (string)FA::stack(['data-role' => 'stack'])
                  ->icon('cog', ['data-role' => 'icon',])
                  ->on('square-o', ['data-role' => 'background']),
              '<span class="fa-stack" data-role="stack"><i class="fa fa-square-o fa-stack-2x" data-role="background"></i><i class="fa fa-cog fa-stack-1x" data-role="icon"></i></span>'
          );
  
          $this->assertEquals(
              (string)FA::stack()
                  ->icon((new Icon('cog'))->spin())
                  ->on((new Icon('square-o'))->size(FA::SIZE_3X)),
              '<span class="fa-stack"><i class="fa fa-square-o fa-3x fa-stack-2x"></i><i class="fa fa-cog fa-spin fa-stack-1x"></i></span>'
          );
280e92c2   Dmitryi   авторизация через...
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  
          $this->assertEquals(
              (string)FA::stack()
                  ->icon(FA::Icon('cog')->spin())
                  ->on(FA::Icon('square-o')->size(FA::SIZE_3X)),
              '<span class="fa-stack"><i class="fa fa-square-o fa-3x fa-stack-2x"></i><i class="fa fa-cog fa-spin fa-stack-1x"></i></span>'
          );
  
          $this->assertNotEquals(
              (string)FA::stack()
                  ->icon((string)FA::Icon('cog')->spin())
                  ->on((string)FA::Icon('square-o')->size(FA::SIZE_3X)),
              '<span class="fa-stack"><i class="fa fa-square-o fa-3x fa-stack-2x"></i><i class="fa fa-cog fa-spin fa-stack-1x"></i></span>'
          );
      }
  
      public function testAnotherPrefix()
      {
          $old_prefix = FA::$cssPrefix;
  
          FA::$cssPrefix = 'fontawesome';
  
          $this->assertEquals(FA::icon('cog'), '<i class="fontawesome fontawesome-cog"></i>');
          $this->assertEquals(FA::icon('cog')->tag('span'), '<span class="fontawesome fontawesome-cog"></span>');
          $this->assertEquals(FA::icon('cog')->addCssClass('highlight'), '<i class="fontawesome fontawesome-cog highlight"></i>');
  
          FA::$cssPrefix = $old_prefix;
e9aa73b0   andryeyev   + adminLte
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
      }
  
      public function testIconOutput()
      {
          $this->assertEquals(FA::icon('cog'), '<i class="fa fa-cog"></i>');
          $this->assertEquals(FA::icon('cog')->tag('span'), '<span class="fa fa-cog"></span>');
          $this->assertEquals(FA::icon('cog')->addCssClass('highlight'), '<i class="fa fa-cog highlight"></i>');
  
          $this->assertEquals(FA::icon('cog')->inverse(), '<i class="fa fa-cog fa-inverse"></i>');
          $this->assertEquals(FA::icon('cog')->spin(), '<i class="fa fa-cog fa-spin"></i>');
          $this->assertEquals(FA::icon('cog')->fixedWidth(), '<i class="fa fa-cog fa-fw"></i>');
          $this->assertEquals(FA::icon('cog')->fixed_width(), '<i class="fa fa-cog fa-fw"></i>');
          $this->assertEquals(FA::icon('cog')->ul(), '<i class="fa fa-cog fa-ul"></i>');
          $this->assertEquals(FA::icon('cog')->li(), '<i class="fa fa-cog fa-li"></i>');
          $this->assertEquals(FA::icon('cog')->border(), '<i class="fa fa-cog fa-border"></i>');
          $this->assertEquals(FA::icon('cog')->pullLeft(), '<i class="fa fa-cog pull-left"></i>');
          $this->assertEquals(FA::icon('cog')->pull_left(), '<i class="fa fa-cog pull-left"></i>');
          $this->assertEquals(FA::icon('cog')->pullRight(), '<i class="fa fa-cog pull-right"></i>');
          $this->assertEquals(FA::icon('cog')->pull_right(), '<i class="fa fa-cog pull-right"></i>');
  
          $this->assertEquals(FA::icon('cog')->size(FA::SIZE_2X), '<i class="fa fa-cog fa-2x"></i>');
          $this->assertEquals(FA::icon('cog')->size(FA::SIZE_3X), '<i class="fa fa-cog fa-3x"></i>');
          $this->assertEquals(FA::icon('cog')->size(FA::SIZE_4X), '<i class="fa fa-cog fa-4x"></i>');
          $this->assertEquals(FA::icon('cog')->size(FA::SIZE_5X), '<i class="fa fa-cog fa-5x"></i>');
          $this->assertEquals(FA::icon('cog')->size(FA::SIZE_LARGE), '<i class="fa fa-cog fa-lg"></i>');
  
          $this->assertEquals(FA::icon('cog')->rotate(FA::ROTATE_90), '<i class="fa fa-cog fa-rotate-90"></i>');
          $this->assertEquals(FA::icon('cog')->rotate(FA::ROTATE_180), '<i class="fa fa-cog fa-rotate-180"></i>');
          $this->assertEquals(FA::icon('cog')->rotate(FA::ROTATE_270), '<i class="fa fa-cog fa-rotate-270"></i>');
  
          $this->assertEquals(FA::icon('cog')->flip(FA::FLIP_HORIZONTAL), '<i class="fa fa-cog fa-flip-horizontal"></i>');
          $this->assertEquals(FA::icon('cog')->flip(FA::FLIP_VERTICAL), '<i class="fa fa-cog fa-flip-vertical"></i>');
      }
  
      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');
      }
280e92c2   Dmitryi   авторизация через...
175
176
177
178
179
180
181
182
183
184
185
  
      public function testIconAddCssClassCondition()
      {
          $this->assertEquals(FA::icon('cog')->addCssClass('highlight', true), '<i class="fa fa-cog highlight"></i>');
  
          $this->setExpectedException(
              'yii\base\InvalidConfigException',
              'Condition is false'
          );
          FA::icon('cog')->addCssClass('highlight', false, true);
      }
e9aa73b0   andryeyev   + adminLte
186
  }