Skip to content

Commit 48aa5d2

Browse files
committed
Merge pull request #85 from matej21/test/validationscope_onvalidate
Test Forms.validationScope: added test for onValidate event
2 parents c2805ef + fe5a54c commit 48aa5d2

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tests/Forms/Forms.validationScope.phpt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@
44
* Test: Nette\Forms validation scope.
55
*/
66

7-
use Nette\Forms\Form;
8-
use Tester\Assert;
7+
use Nette\Forms\Container,
8+
Nette\Forms\Form,
9+
Tester\Assert;
910

1011

1112
require __DIR__ . '/../bootstrap.php';
1213

1314

1415
$datasets = [
15-
['send1', ['name', 'age', 'age2']],
16-
['send2', []],
17-
['send3', ['name']],
18-
['send4', ['age']],
19-
['send5', ['age', 'age2']],
16+
['send1', ['container', 'form', 'name', 'age', 'age2']],
17+
['send2', ['form']],
18+
['send3', ['form', 'name']],
19+
['send4', ['form', 'age']],
20+
['send5', ['container', 'form', 'age', 'age2']],
2021
];
2122

2223
foreach ($datasets as $case) {
2324

2425
$form = new Form;
26+
$form->onValidate[] = function (Form $form) {
27+
$form->addError('form');
28+
};
2529
$form->addText('name')->setRequired('name');
2630

2731
$details = $form->addContainer('details');
32+
$details->onValidate[] = function (Container $container) {
33+
$container->getForm()->addError('container');
34+
};
2835
$details->addText('age')->setRequired('age');
2936
$details->addText('age2')->setRequired('age2');
3037

0 commit comments

Comments
 (0)