|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Yiisoft\Yii\Widgets\Tests\Alert; |
|
6
|
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
|
8
|
|
|
use Yiisoft\Definitions\Exception\CircularReferenceException; |
|
9
|
|
|
use Yiisoft\Definitions\Exception\InvalidConfigException; |
|
10
|
|
|
use Yiisoft\Definitions\Exception\NotInstantiableException; |
|
11
|
|
|
use Yiisoft\Factory\NotFoundException; |
|
12
|
|
|
use Yiisoft\Yii\Widgets\Alert; |
|
13
|
|
|
use Yiisoft\Yii\Widgets\Tests\Support\Assert; |
|
14
|
|
|
use Yiisoft\Yii\Widgets\Tests\Support\TestTrait; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @psalm-suppress PropertyNotSetInConstructor |
|
18
|
|
|
*/ |
|
19
|
|
|
final class BulmaTest extends TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
use TestTrait; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @link https://bulma.io/documentation/elements/notification/ |
|
25
|
|
|
* |
|
26
|
|
|
* @throws CircularReferenceException |
|
27
|
|
|
* @throws InvalidConfigException |
|
28
|
|
|
* @throws NotFoundException |
|
29
|
|
|
* @throws NotInstantiableException |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testNotification(): void |
|
32
|
|
|
{ |
|
33
|
|
|
Assert::equalsWithoutLE( |
|
34
|
|
|
<<<HTML |
|
35
|
|
|
<div id="w0-alert" class="notification is-danger" role="alert"> |
|
36
|
|
|
<span>An example alert with an icon.</span> |
|
37
|
|
|
<button type="button" class="delete">×</button> |
|
38
|
|
|
</div> |
|
39
|
|
|
HTML, |
|
40
|
|
|
Alert::widget() |
|
41
|
|
|
->body('An example alert with an icon.') |
|
|
|
|
|
|
42
|
|
|
->buttonClass('delete') |
|
43
|
|
|
->class('notification is-danger') |
|
44
|
|
|
->id('w0-alert') |
|
45
|
|
|
->layoutBody('{body}{button}') |
|
46
|
|
|
->render(), |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @throws CircularReferenceException |
|
52
|
|
|
* @throws InvalidConfigException |
|
53
|
|
|
* @throws NotFoundException |
|
54
|
|
|
* @throws NotInstantiableException |
|
55
|
|
|
*/ |
|
56
|
|
|
public function testNotificationWithIcon(): void |
|
57
|
|
|
{ |
|
58
|
|
|
Assert::equalsWithoutLE( |
|
59
|
|
|
<<<HTML |
|
60
|
|
|
<div id="w0-alert" class="notification is-danger" role="alert"> |
|
61
|
|
|
<button type="button" class="delete">×</button> |
|
62
|
|
|
<div class="is-flex is-align-items-center"> |
|
63
|
|
|
<div><i class="fa-2x fas fa-exclamation-circle mr-4"></i></div> |
|
64
|
|
|
<span>An example alert with an icon.</span> |
|
65
|
|
|
</div> |
|
66
|
|
|
</div> |
|
67
|
|
|
HTML, |
|
68
|
|
|
Alert::widget() |
|
69
|
|
|
->body('An example alert with an icon.') |
|
70
|
|
|
->bodyContainer(true) |
|
71
|
|
|
->bodyContainerClass('is-flex is-align-items-center') |
|
72
|
|
|
->buttonClass('delete') |
|
73
|
|
|
->class('notification is-danger') |
|
74
|
|
|
->iconClass('fa-2x fas fa-exclamation-circle mr-4') |
|
75
|
|
|
->id('w0-alert') |
|
76
|
|
|
->layoutBody('{icon}{body}') |
|
77
|
|
|
->layoutHeader('{button}') |
|
78
|
|
|
->render(), |
|
79
|
|
|
); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|