|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ControlTests; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use CommonTestClass; |
|
7
|
|
|
use kalanis\kw_forms\Controls; |
|
8
|
|
|
use kalanis\kw_forms\Exceptions\RenderException; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class TextTest extends CommonTestClass |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @throws RenderException |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testInput(): void |
|
17
|
|
|
{ |
|
18
|
|
|
$input = new Controls\Input(); |
|
19
|
|
|
$input->set('text', 'myown', 'original', 'not to look'); |
|
20
|
|
|
$this->assertEquals('<input value="original" type="text" id="myown" name="myown" />', $input->renderInput()); |
|
21
|
|
|
$input->setValue('jhgfd'); |
|
22
|
|
|
$this->assertEquals('<input value="jhgfd" type="text" id="myown" name="myown" />', $input->renderInput()); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @throws RenderException |
|
27
|
|
|
*/ |
|
28
|
|
|
public function testText(): void |
|
29
|
|
|
{ |
|
30
|
|
|
$input = new Controls\Text(); |
|
31
|
|
|
$input->set('myown', 'original', 'not to look'); |
|
32
|
|
|
$this->assertEquals('<input type="text" value="original" id="myown" name="myown" />', $input->renderInput()); |
|
33
|
|
|
$input->setValue('jhgfd'); |
|
34
|
|
|
$this->assertEquals('<input type="text" value="jhgfd" id="myown" name="myown" />', $input->renderInput()); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @throws RenderException |
|
39
|
|
|
*/ |
|
40
|
|
|
public function testTextarea(): void |
|
41
|
|
|
{ |
|
42
|
|
|
$input = new Controls\Textarea(); |
|
43
|
|
|
$input->set('myown', 'original', 'not to look'); |
|
44
|
|
|
$this->assertEquals('<textarea id="myown" name="myown">original</textarea>', $input->renderInput()); |
|
45
|
|
|
$input->setValue('jhgfd'); |
|
46
|
|
|
$this->assertEquals('<textarea id="myown" name="myown">jhgfd</textarea>', $input->renderInput()); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @throws RenderException |
|
51
|
|
|
*/ |
|
52
|
|
|
public function testEmail(): void |
|
53
|
|
|
{ |
|
54
|
|
|
$input = new Controls\Email(); |
|
55
|
|
|
$input->set('myown', 'original', 'not to look'); |
|
56
|
|
|
$this->assertEquals('<input type="email" value="original" id="myown" name="myown" />', $input->renderInput()); |
|
57
|
|
|
$input->setValue('jhgfd'); |
|
58
|
|
|
$this->assertEquals('<input type="email" value="jhgfd" id="myown" name="myown" />', $input->renderInput()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @throws RenderException |
|
63
|
|
|
*/ |
|
64
|
|
|
public function testPassword(): void |
|
65
|
|
|
{ |
|
66
|
|
|
$input = new Controls\Password(); |
|
67
|
|
|
$input->set('myown', 'not to look'); |
|
68
|
|
|
$this->assertEquals('<input type="password" value="" id="myown" name="myown" />', $input->renderInput()); |
|
69
|
|
|
$input->setValue('jhgfd'); |
|
70
|
|
|
$this->assertEquals('<input type="password" value="" id="myown" name="myown" />', $input->renderInput()); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @throws RenderException |
|
75
|
|
|
*/ |
|
76
|
|
|
public function testPhone(): void |
|
77
|
|
|
{ |
|
78
|
|
|
$input = new Controls\Telephone(); |
|
79
|
|
|
$input->set('myown', 'original', 'not to look'); |
|
80
|
|
|
$this->assertEquals('<input type="tel" value="original" id="myown" name="myown" />', $input->renderInput()); |
|
81
|
|
|
$input->setValue('jhgfd'); |
|
82
|
|
|
$this->assertEquals('<input type="tel" value="jhgfd" id="myown" name="myown" />', $input->renderInput()); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|