Completed
Push — master ( 55aead...307710 )
by Wilmer
02:36
created

CdnCssCest   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 227
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 12
eloc 71
c 1
b 0
f 0
dl 0
loc 227
rs 10
1
<?php
2
3
namespace terabytesoft\assets\fontawesome\tests;
4
5
use terabytesoft\assets\FontAwesome\tests\UnitTester;
6
use terabytesoft\assets\fontawesome\cdn\css\CdnAllAsset;
7
use terabytesoft\assets\fontawesome\cdn\css\CdnBrandAsset;
8
use terabytesoft\assets\fontawesome\cdn\css\CdnFontAwesomeAsset;
9
use terabytesoft\assets\fontawesome\cdn\css\CdnRegularAsset;
10
use terabytesoft\assets\fontawesome\cdn\css\CdnSolidAsset;
11
use yii\web\AssetBundle;
12
use yii\web\View;
13
14
/**
15
 * Class CdnCssCest
16
 *
17
 * Unit tests for codeception cdn fontawesome css
18
 */
19
class CdnCssCest
20
{
21
    /**
22
     * @var \yii\web\View;
23
     */
24
    private $view;
25
26
    /**
27
     *  _before
28
     *
29
     * @param UnitTester $I
30
     */
31
    public function _before(UnitTester $I): void
32
    {
33
        $this->view = new View();
34
    }
35
36
    /**
37
     * _after
38
     *
39
     * @param UnitTester $I
40
     */
41
    public function _after(UnitTester $I): void
42
    {
43
        unset($this->view);
44
    }
45
46
    /**
47
     * testCdnAllAssetRegister
48
     *
49
     * @param UnitTester $I
50
     */
51
    public function testCdnAllAssetRegister(UnitTester $I): void
52
    {
53
        $I->assertEmpty($this->view->assetBundles);
54
55
        CdnAllAsset::register($this->view);
56
57
        $I->assertCount(1, $this->view->assetBundles);
58
59
        $I->assertArrayHasKey(CdnAllAsset::class, $this->view->assetBundles);
60
61
        $result = $this->view->renderFile(codecept_data_dir() . 'main.php');
62
63
        $I->assertRegexp('/all.css/', $result);
64
    }
65
66
    /**
67
     * testCdnBrandAssetRegister
68
     *
69
     * @param UnitTester $I
70
     */
71
    public function testCdnBrandAssetRegister(UnitTester $I): void
72
    {
73
        $I->assertEmpty($this->view->assetBundles);
74
75
        CdnBrandAsset::register($this->view);
76
77
        $I->assertCount(2, $this->view->assetBundles);
78
79
        $I->assertArrayHasKey(CdnBrandAsset::class, $this->view->assetBundles);
80
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
81
82
        $result = $this->view->renderFile(codecept_data_dir() . 'main.php');
83
84
        $I->assertRegexp('/brands.css/', $result);
85
        $I->assertRegexp('/fontawesome.css/', $result);
86
    }
87
88
    /**
89
     * testCdnFontAwesomeAssetRegister
90
     *
91
     * @param UnitTester $I
92
     */
93
    public function testCdnFontAwesomeAssetRegister(UnitTester $I): void
94
    {
95
        $I->assertEmpty($this->view->assetBundles);
96
97
        CdnFontAwesomeAsset::register($this->view);
98
99
        $I->assertCount(1, $this->view->assetBundles);
100
101
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
102
103
        $result = $this->view->renderFile(codecept_data_dir() . 'main.php');
104
105
        $I->assertRegexp('/fontawesome.css/', $result);
106
    }
107
108
    /**
109
     * testCdnRegularAssetRegister
110
     *
111
     * @param UnitTester $I
112
     */
113
    public function testCdnRegularAssetRegister(UnitTester $I): void
114
    {
115
        $I->assertEmpty($this->view->assetBundles);
116
117
        CdnRegularAsset::register($this->view);
118
119
        $I->assertCount(2, $this->view->assetBundles);
120
121
        $I->assertArrayHasKey(CdnRegularAsset::class, $this->view->assetBundles);
122
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
123
124
        $result = $this->view->renderFile(codecept_data_dir() . 'main.php');
125
126
        $I->assertRegexp('/regular.css/', $result);
127
        $I->assertRegexp('/fontawesome.css/', $result);
128
    }
129
130
    /**
131
     * testCdnSolidAssetRegister
132
     *
133
     * @param UnitTester $I
134
     */
135
    public function testCdnSolidAssetRegister(UnitTester $I): void
136
    {
137
        $I->assertEmpty($this->view->assetBundles);
138
139
        CdnSolidAsset::register($this->view);
140
141
        $I->assertCount(2, $this->view->assetBundles);
142
143
        $I->assertArrayHasKey(CdnSolidAsset::class, $this->view->assetBundles);
144
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
145
146
        $result = $this->view->renderFile(codecept_data_dir() . 'main.php');
147
148
        $I->assertRegexp('/solid.css/', $result);
149
        $I->assertRegexp('/fontawesome.css/', $result);
150
    }
151
152
    /**
153
     * testCdnAllAssetSimpleDependency
154
     *
155
     * @param UnitTester $I
156
     */
157
    public function testCdnAllAssetSimpleDependency(UnitTester $I): void
158
    {
159
        $I->assertEmpty($this->view->assetBundles);
160
161
        CdnAllAsset::register($this->view);
162
163
        $I->assertCount(1, $this->view->assetBundles);
164
165
        $I->assertArrayHasKey(CdnAllAsset::class, $this->view->assetBundles);
166
167
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnAllAsset::class]);
168
    }
169
170
    /**
171
     * testCdnBrandAssetSimpleDependency
172
     *
173
     * @param UnitTester $I
174
     */
175
    public function testCdnBrandAssetSimpleDependency(UnitTester $I): void
176
    {
177
        $I->assertEmpty($this->view->assetBundles);
178
179
        CdnBrandAsset::register($this->view);
180
181
        $I->assertCount(2, $this->view->assetBundles);
182
183
        $I->assertArrayHasKey(CdnBrandAsset::class, $this->view->assetBundles);
184
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
185
186
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnBrandAsset::class]);
187
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnFontAwesomeAsset::class]);
188
    }
189
190
    /**
191
     * testCdnFontAwesomeAssetSimpleDependency
192
     *
193
     * @param UnitTester $I
194
     */
195
    public function testCdnFontAwesomeAssetSimpleDependency(UnitTester $I): void
196
    {
197
        $I->assertEmpty($this->view->assetBundles);
198
199
        CdnFontAwesomeAsset::register($this->view);
200
201
        $I->assertCount(1, $this->view->assetBundles);
202
203
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
204
205
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnFontAwesomeAsset::class]);
206
    }
207
208
    /**
209
     * testCdnRegularAssetSimpleDependency
210
     *
211
     * @param UnitTester $I
212
     */
213
    public function testCdnRegularAssetSimpleDependency(UnitTester $I): void
214
    {
215
        $I->assertEmpty($this->view->assetBundles);
216
217
        CdnRegularAsset::register($this->view);
218
219
        $I->assertCount(2, $this->view->assetBundles);
220
221
        $I->assertArrayHasKey(CdnRegularAsset::class, $this->view->assetBundles);
222
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
223
224
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnRegularAsset::class]);
225
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnFontAwesomeAsset::class]);
226
    }
227
228
    /**
229
     * testCdnSolidAssetSimpleDependency
230
     *
231
     * @param UnitTester $I
232
     */
233
    public function testCdnSolidAssetSimpleDependency(UnitTester $I): void
234
    {
235
        $I->assertEmpty($this->view->assetBundles);
236
237
        CdnSolidAsset::register($this->view);
238
239
        $I->assertCount(2, $this->view->assetBundles);
240
241
        $I->assertArrayHasKey(CdnSolidAsset::class, $this->view->assetBundles);
242
        $I->assertArrayHasKey(CdnFontAwesomeAsset::class, $this->view->assetBundles);
243
244
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnSolidAsset::class]);
245
        $I->assertInstanceOf(AssetBundle::class, $this->view->assetBundles[CdnFontAwesomeAsset::class]);
246
    }
247
}
248