-
-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathControls.ImageButton.render.phpt
More file actions
71 lines (48 loc) 路 1.62 KB
/
Copy pathControls.ImageButton.render.phpt
File metadata and controls
71 lines (48 loc) 路 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Test: Nette\Forms\Controls\Button.
*/
declare(strict_types=1);
use Nette\Forms\Form;
use Nette\Utils\Html;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
class Translator implements Nette\Localization\ITranslator
{
public function translate($s, ...$parameters): string
{
return strtoupper($s);
}
}
test(function () {
$form = new Form;
$input = $form->addImage('button', 'image.gif');
Assert::null($input->getLabel());
Assert::type(Html::class, $input->getControl());
Assert::same('<input type="image" name="button[]" src="image.gif">', (string) $input->getControl());
});
test(function () { // translator
$form = new Form;
$input = $form->addImage('button', 'image.gif');
$input->setTranslator(new Translator);
Assert::same('<input type="image" name="button[]" src="image.gif">', (string) $input->getControl());
});
test(function () { // no validation rules
$form = new Form;
$input = $form->addImage('button', 'image.gif')->setRequired('required');
Assert::same('<input type="image" name="button[]" src="image.gif">', (string) $input->getControl());
});
test(function () { // container
$form = new Form;
$container = $form->addContainer('container');
$input = $container->addImage('button', 'image.gif');
Assert::same('<input type="image" name="container[button][]" src="image.gif">', (string) $input->getControl());
});
test(function () { // rendering options
$form = new Form;
$input = $form->addImage('button');
Assert::same('button', $input->getOption('type'));
Assert::null($input->getOption('rendered'));
$input->getControl();
Assert::true($input->getOption('rendered'));
});