Completed
Push — develop ( b2b49f...eda620 )
by Mathieu
01:53
created

FormItemTest::testInputTextarea()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
b 1
f 0
1
<?php
2
3
use \Suricate\FormItem;
4
5
/**
6
 * @SuppressWarnings("StaticAccess")
7
 */
8
class FormItemTest extends \PHPUnit\Framework\TestCase
9
{
10
    public function testInput()
11
    {
12
        $res = FormItem::input('text', 'myInput', "accentué", 'Mon input');
13
        $this->assertEquals(
14
            '<label for="myInput">Mon input</label><input type="text" name="myInput" id="myInput" value="accentu&eacute;"/>',
15
            $res
16
        );
17
18
        $res = FormItem::input('text', 'myInput', null, 'Mon input');
19
        $this->assertEquals(
20
            '<label for="myInput">Mon input</label><input type="text" name="myInput" id="myInput"/>',
21
            $res
22
        );
23
24
        $res = FormItem::input('text', 'myInput', "testval");
25
        $this->assertEquals(
26
            '<input type="text" name="myInput" value="testval"/>',
27
            $res
28
        );
29
    }
30
31
    public function testInputText()
32
    {
33
        $res = FormItem::text('my-input-name', "accentué", 'Mon input');
34
        $this->assertEquals(
35
            '<label for="my-input-name">Mon input</label><input type="text" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
36
            $res
37
        );
38
    }
39
40
    public function testInputPassword()
41
    {
42
        $res = FormItem::password('my-input-name', "accentué", 'Mon input');
43
        $this->assertEquals(
44
            '<label for="my-input-name">Mon input</label><input type="password" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
45
            $res
46
        );
47
    }
48
49
    public function testInputNumber()
50
    {
51
        $res = FormItem::number('my-input-name', "accentué", 'Mon input');
52
        $this->assertEquals(
53
            '<label for="my-input-name">Mon input</label><input type="number" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
54
            $res
55
        );
56
    }
57
58
    public function testInputFile()
59
    {
60
        $res = FormItem::file('my-input-name', "Mon input");
61
        $this->assertEquals(
62
            '<label for="my-input-name">Mon input</label><input type="file" name="my-input-name" id="my-input-name"/>',
63
            $res
64
        );
65
    }
66
67
    public function testInputHidden()
68
    {
69
        $res = FormItem::hidden('my-input-name', "accentué");
70
        $this->assertEquals(
71
            '<input type="hidden" name="my-input-name" value="accentu&eacute;"/>',
72
            $res
73
        );
74
    }
75
76
    public function testInputSubmit()
77
    {
78
        $res = FormItem::submit('my-input-name', "accentué", 'Mon input');
79
        $this->assertEquals(
80
            '<label for="my-input-name">Mon input</label><input type="submit" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
81
            $res
82
        );
83
    }
84
85
    public function testInputTextarea()
86
    {
87
        $res = FormItem::textarea('my-input-name', "accentué", 'Mon input');
88
        $this->assertEquals(
89
            '<label for="my-input-name">Mon input</label><textarea name="my-input-name" id="my-input-name">accentué</textarea>',
90
            $res
91
        );
92
    }
93
94
    public function testInputTel()
95
    {
96
        $res = FormItem::tel('my-input-name', "accentué", 'Mon input');
97
        $this->assertEquals(
98
            '<label for="my-input-name">Mon input</label><input type="tel" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
99
            $res
100
        );
101
    }
102
103
    public function testInputUrl()
104
    {
105
        $res = FormItem::url('my-input-name', "accentué", 'Mon input');
106
        $this->assertEquals(
107
            '<label for="my-input-name">Mon input</label><input type="url" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
108
            $res
109
        );
110
    }
111
112
    public function testInputEmail()
113
    {
114
        $res = FormItem::email('my-input-name', "accentué", 'Mon input');
115
        $this->assertEquals(
116
            '<label for="my-input-name">Mon input</label><input type="email" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
117
            $res
118
        );
119
    }
120
121
    public function testInputSearch()
122
    {
123
        $res = FormItem::search('my-input-name', "accentué", 'Mon input');
124
        $this->assertEquals(
125
            '<label for="my-input-name">Mon input</label><input type="search" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
126
            $res
127
        );
128
    }
129
130
    public function testInputDate()
131
    {
132
        $res = FormItem::date('my-input-name', "accentué", 'Mon input');
133
        $this->assertEquals(
134
            '<label for="my-input-name">Mon input</label><input type="date" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
135
            $res
136
        );
137
    }
138
139
    public function testInputDateTime()
140
    {
141
        $res = FormItem::datetime('my-input-name', "accentué", 'Mon input');
142
        $this->assertEquals(
143
            '<label for="my-input-name">Mon input</label><input type="datetime" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
144
            $res
145
        );
146
    }
147
148
    public function testInputTime()
149
    {
150
        $res = FormItem::time('my-input-name', "accentué", 'Mon input');
151
        $this->assertEquals(
152
            '<label for="my-input-name">Mon input</label><input type="time" name="my-input-name" id="my-input-name" value="accentu&eacute;"/>',
153
            $res
154
        );
155
    }
156
}
157