Completed
Push — master ( 95aedb...06e367 )
by Alexey
15:04
created

AlertTest::testGetOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace tests;
4
5
use dominus77\sweetalert2\Alert;
6
use yii\helpers\Json;
7
8
/**
9
 * Class AlertTest
10
 * @package tests
11
 */
12
class AlertTest extends TestCase
13
{
14
    /**
15
     * getOptions()
16
     */
17
    public function testGetOptions()
18
    {
19
        $alert = new Alert();
20
        $alert->options = [
21
            'id' => 'test_id',
22
            'Any fool can use a computer'
23
        ];
24
        $this->assertJson(Json::encode($alert->options), $alert->getOptions());
25
    }
26
27
    public function testRegisterSwalQueue()
28
    {
29
        \Yii::$app->session->setFlash('success', 'Your message');
30
        $alert = Alert::widget(['useSessionFlash' => true]);
31
        $this->assertContains('', $alert);
32
    }
33
34
    public function testRunFlash()
35
    {
36
        \Yii::$app->session->setFlash('success', [
37
            [
38
                'title' => 'Your title',
39
                'message' => 'Your message',
40
                'animation' => false,
41
                'customClass' => 'animated jello',
42
            ]
43
        ]);
44
45
        $alert = Alert::widget(['useSessionFlash' => true]);
46
        $this->assertContains('', $alert);
47
    }
48
49
    public function testRegisterSwal()
50
    {
51
        $alert = Alert::widget([
52
            'options' => [
53
                'title' => 'Your title',
54
                'message' => 'Your message',
55
                'animation' => false,
56
                'customClass' => 'animated jello', // https://daneden.github.io/animate.css/
57
            ],
58
        ]);
59
        $this->assertContains('', $alert);
60
    }
61
}