Passed
Push — master ( f02495...4136df )
by Alexander
01:44
created

AlertTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
dl 0
loc 46
rs 10
c 1
b 0
f 0
wmc 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Bootstrap4\Tests;
6
7
use Yiisoft\Yii\Bootstrap4\Alert;
8
9
/**
10
 * Tests for Alert widget
11
 *
12
 * AlertTest.
13
 */
14
final class AlertTest extends TestCase
15
{
16
    public function testNormalAlert(): void
17
    {
18
        Alert::counter(0);
19
20
        $html = Alert::widget()
21
            ->body('<strong>Holy guacamole!</strong> You should check in on some of those fields below.')
22
            ->options([
23
                'class' => ['alert-warning']
24
            ])
25
            ->render();
26
27
        $expectedHtml = <<<HTML
28
<div id="w0-alert" class="alert-warning alert alert-dismissible" role="alert">
29
30
<strong>Holy guacamole!</strong> You should check in on some of those fields below.
31
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>
32
33
</div>
34
HTML;
35
36
        $this->assertEqualsWithoutLE($expectedHtml, $html);
37
    }
38
39
    /**
40
     * @depends testNormalAlert
41
     */
42
    public function testDismissibleAlert(): void
43
    {
44
        Alert::counter(0);
45
46
        $html = Alert::widget()
47
            ->body("Message1")
48
            ->render();
49
50
        $expectedHtml = <<<HTML
51
<div id="w0-alert" class="alert alert-dismissible" role="alert">
52
53
Message1
54
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>
55
56
</div>
57
HTML;
58
59
        $this->assertEqualsWithoutLE($expectedHtml, $html);
60
    }
61
}
62