Skip to content

Commit

Permalink
tests: improved descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 29, 2025
1 parent 6f74d2c commit ccc7403
Show file tree
Hide file tree
Showing 60 changed files with 465 additions and 465 deletions.
10 changes: 5 additions & 5 deletions tests/Forms/Container.values.ArrayHash.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function createForm(): Form
}


test('setDefaults() + iterable', function () {
test('Setting defaults using ArrayHash', function () {
$form = createForm();
Assert::false($form->isSubmitted());

Expand Down Expand Up @@ -69,7 +69,7 @@ test('setDefaults() + iterable', function () {
});


test('submitted form + getValues()', function () {
test('Retrieving POST data as ArrayHash', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand All @@ -87,7 +87,7 @@ test('submitted form + getValues()', function () {
});


test('submitted form + reset()', function () {
test('Resetting form with ArrayHash values', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand All @@ -109,7 +109,7 @@ test('submitted form + reset()', function () {
});


test('setValues() + iterable', function () {
test('Updating values with ArrayHash and erase', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand Down Expand Up @@ -154,7 +154,7 @@ test('setValues() + iterable', function () {
});


test('onSuccess test', function () {
test('onSuccess event with ArrayHash values', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand Down
20 changes: 10 additions & 10 deletions tests/Forms/Container.values.array.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function createForm(): Form
}


test('setDefaults() + array', function () {
test('Setting form defaults and retrieving array values', function () {
$form = createForm();
Assert::false($form->isSubmitted());

Expand Down Expand Up @@ -69,7 +69,7 @@ test('setDefaults() + array', function () {
});


test('submitted form + getValues(array)', function () {
test('Handles POST submission with nested data', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand All @@ -87,7 +87,7 @@ test('submitted form + getValues(array)', function () {
});


test('submitted form + reset()', function () {
test('Resetting form clears submitted values', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand All @@ -109,7 +109,7 @@ test('submitted form + reset()', function () {
});


test('setValues() + array', function () {
test('Setting form values with erase option', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand Down Expand Up @@ -154,7 +154,7 @@ test('setValues() + array', function () {
});


test('getValues(...arguments...)', function () {
test('Updating form values without erasing', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand All @@ -181,7 +181,7 @@ test('getValues(...arguments...)', function () {
});


test('setMappedType(array)', function () {
test('Using array as mapped type for form values', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand Down Expand Up @@ -209,7 +209,7 @@ test('setMappedType(array)', function () {
});


test('onSuccess test', function () {
test('Triggering onSuccess with correct value types', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';

$form = createForm();
Expand Down Expand Up @@ -262,7 +262,7 @@ test('onSuccess test', function () {
});


test('submitted form + setValidationScope() + getValues(array)', function () {
test('Validation scope limits submitted data', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['send'] = '';

Expand All @@ -280,7 +280,7 @@ test('submitted form + setValidationScope() + getValues(array)', function () {
});


test('submitted form + setValidationScope() + getValues(array)', function () {
test('Validation scope applied to container', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['send'] = '';

Expand All @@ -297,7 +297,7 @@ test('submitted form + setValidationScope() + getValues(array)', function () {
], $form['first']->getValues('array'));
});

test('submitted form + setValidationScope() + getValues(array)', function () {
test('Validation scope on nested container fields', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['send'] = '';

Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Container.values.mapping-constructor.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function createForm(): Form
}


test('getValues(...arguments...)', function () {
test('Mapping form values to constructor-injected objects', function () {
$form = createForm();

$form->setValues([
Expand Down
2 changes: 1 addition & 1 deletion tests/Forms/Container.values.mapping-enum.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FormWithEnum
}


test('getValues() + enum', function () {
test('Handling enum types in form data', function () {
$form = new Form;
$form->addText('enum1');
$form->addText('enum2')->setNullable();
Expand Down
18 changes: 9 additions & 9 deletions tests/Forms/Container.values.mapping.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function createForm(): Form
}


test('setDefaults() + object', function () {
test('Setting defaults using object mapping', function () {
$_SERVER['REQUEST_METHOD'] = null;

$form = createForm();
Expand Down Expand Up @@ -97,7 +97,7 @@ test('setDefaults() + object', function () {
});


test('submitted form + getValues()', function () {
test('Mapping POST data to objects', function () {
$form = createForm();
$form->setMappedType(FormData::class);

Expand All @@ -115,7 +115,7 @@ test('submitted form + getValues()', function () {
});


test('submitted form + reset()', function () {
test('Resetting form with object-mapped values', function () {
$form = createForm();
$form->setMappedType(FormData::class);

Expand All @@ -137,7 +137,7 @@ test('submitted form + reset()', function () {
});


test('setValues() + object', function () {
test('Updating object-mapped values with erase', function () {
$form = createForm();
$form->setMappedType(FormData::class);

Expand Down Expand Up @@ -183,7 +183,7 @@ test('setValues() + object', function () {
});


test('getValues(...arguments...)', function () {
test('Mixed object and array value mapping', function () {
$_SERVER['REQUEST_METHOD'] = null;

$form = createForm();
Expand Down Expand Up @@ -234,7 +234,7 @@ test('getValues(...arguments...)', function () {
});


test('onSuccess test', function () {
test('onSuccess with multiple mapped value types', function () {
$form = createForm();
$form->setMappedType(FormData::class);

Expand Down Expand Up @@ -300,7 +300,7 @@ test('onSuccess test', function () {
});


test('getValues() + object', function () {
test('Populating existing object with form values', function () {
$form = createForm();
$obj = $orig = new FormData;

Expand All @@ -319,7 +319,7 @@ test('getValues() + object', function () {
});


test('submitted form + setValidationScope() + getValues()', function () {
test('Validation scope on object-mapped fields', function () {
$_POST['send'] = '';

$form = createForm();
Expand All @@ -336,7 +336,7 @@ test('submitted form + setValidationScope() + getValues()', function () {
});


test('submitted form + setValidationScope() + getValues()', function () {
test('Validation scope on nested object fields', function () {
$_POST['send'] = '';

$form = createForm();
Expand Down
18 changes: 9 additions & 9 deletions tests/Forms/Controls.BaseControl.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ setUp(function () {
});


test('error handling', function () {
test('Error handling for required text input', function () {
$form = new Form;
$input = $form->addText('text')
->setRequired('error');
Expand All @@ -40,7 +40,7 @@ test('error handling', function () {
});


test('validators', function () {
test('Validation methods for text input values', function () {
$form = new Form;
$input = $form->addText('text');
$input->setValue(123);
Expand Down Expand Up @@ -77,7 +77,7 @@ test('validators', function () {
});


test('validators for array', function () {
test('MultiSelect validation and length checks', function () {
$form = new Form;
$input = $form->addMultiSelect('select', null, ['a', 'b', 'c', 'd']);
$input->setValue([1, 2, 3]);
Expand All @@ -100,23 +100,23 @@ test('validators for array', function () {
});


test('setHtmlId', function () {
test('Custom HTML ID for text input', function () {
$form = new Form;
$input = $form->addText('text')->setHtmlId('myId');

Assert::same('<input type="text" name="text" id="myId">', (string) $input->getControl());
});


test('special name', function () {
test('Input name conflict resolution', function () {
$form = new Form;
$input = $form->addText('submit');

Assert::same('<input type="text" name="_submit" id="frm-submit">', (string) $input->getControl());
});


test('disabled', function () {
test('Disabled input retains default value', function () {
$form = new Form;
$form->addText('disabled')
->setDisabled()
Expand All @@ -128,7 +128,7 @@ test('disabled', function () {
});


test('disabled & submitted', function () {
test('Disabled inputs ignore POST data', function () {
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST = ['disabled' => 'submitted value'];
$_COOKIE[Nette\Http\Helpers::StrictCookieName] = '1';
Expand Down Expand Up @@ -156,7 +156,7 @@ test('disabled & submitted', function () {
});


test('', function () {
test('Translator integration for labels and errors', function () {
$form = new Form;
$form->setTranslator(new class implements Nette\Localization\ITranslator {
public function translate($s, ...$parameters): string
Expand Down Expand Up @@ -190,7 +190,7 @@ test('', function () {
});


test('change HTML name', function () {
test('Dynamic HTML name attribute handling', function () {
$_POST = ['b' => '123', 'send' => ''];
$form = new Form;
$form->addSubmit('send', 'Send');
Expand Down
8 changes: 4 additions & 4 deletions tests/Forms/Controls.Button.loadData.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ setUp(function () {
});


test('', function () {
test('Submit button captures POST value', function () {
$_POST = [
'button' => 'x',
];
Expand All @@ -34,7 +34,7 @@ test('', function () {
});


test('empty value', function () {
test('Submit button with empty and zero values', function () {
$_POST = [
'button1' => '',
'button2' => '0',
Expand All @@ -52,15 +52,15 @@ test('empty value', function () {
});


test('missing data', function () {
test('Unsubmitted button state', function () {
$form = new Form;
$input = $form->addSubmit('button');
Assert::false($input->isFilled());
Assert::null($input->getValue());
});


test('malformed data', function () {
test('Handling malformed POST data for button', function () {
$_POST = [
'malformed' => [],
];
Expand Down
Loading

0 comments on commit ccc7403

Please sign in to comment.