Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Expand test matrix with nonempty value scenarios #46

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/FileInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ public function isRequiredVsAllowEmptyVsContinueIfEmptyVsIsValidProvider()
$dataSets = parent::isRequiredVsAllowEmptyVsContinueIfEmptyVsIsValidProvider();

// FileInput do not use NotEmpty validator so the only validator present in the chain is the custom one.
unset($dataSets['Required: T; AEmpty: F; CIEmpty: F; Validator: X / tmp_name']);
unset($dataSets['Required: T; AEmpty: F; CIEmpty: F; Validator: X / single']);
unset($dataSets['Required: T; AEmpty: F; CIEmpty: F; Validator: X / multi']);
unset($dataSets['Required: T; AEmpty: F; CIEmpty: F; Validator: X, Value: Empty / tmp_name']);
unset($dataSets['Required: T; AEmpty: F; CIEmpty: F; Validator: X, Value: Empty / single']);
unset($dataSets['Required: T; AEmpty: F; CIEmpty: F; Validator: X, Value: Empty / multi']);

return $dataSets;
}
Expand Down
59 changes: 39 additions & 20 deletions test/InputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ public function setValueProvider()

public function isRequiredVsAllowEmptyVsContinueIfEmptyVsIsValidProvider()
{
$allValues = $this->setValueProvider();
$emptyValues = $this->emptyValueProvider();
$nonEmptyValues = array_diff_key($allValues, $emptyValues);

$isRequired = true;
$aEmpty = true;
Expand All @@ -565,18 +567,33 @@ public function isRequiredVsAllowEmptyVsContinueIfEmptyVsIsValidProvider()
// @codingStandardsIgnoreStart
$dataTemplates=[
// Description => [$isRequired, $allowEmpty, $continueIfEmpty, $validator, [$values], $expectedIsValid, $expectedMessages]
'Required: T; AEmpty: T; CIEmpty: T; Validator: T' => [ $isRequired, $aEmpty, $cIEmpty, $validatorValid , $emptyValues, $isValid, []],
'Required: T; AEmpty: T; CIEmpty: T; Validator: F' => [ $isRequired, $aEmpty, $cIEmpty, $validatorInvalid, $emptyValues, !$isValid, $validatorMsg],
'Required: T; AEmpty: T; CIEmpty: F; Validator: X' => [ $isRequired, $aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues, $isValid, []],
'Required: T; AEmpty: F; CIEmpty: T; Validator: T' => [ $isRequired, !$aEmpty, $cIEmpty, $validatorValid , $emptyValues, $isValid, []],
'Required: T; AEmpty: F; CIEmpty: T; Validator: F' => [ $isRequired, !$aEmpty, $cIEmpty, $validatorInvalid, $emptyValues, !$isValid, $validatorMsg],
'Required: T; AEmpty: F; CIEmpty: F; Validator: X' => [ $isRequired, !$aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues, !$isValid, $notEmptyMsg],
'Required: F; AEmpty: T; CIEmpty: T; Validator: T' => [!$isRequired, $aEmpty, $cIEmpty, $validatorValid , $emptyValues, $isValid, []],
'Required: F; AEmpty: T; CIEmpty: T; Validator: F' => [!$isRequired, $aEmpty, $cIEmpty, $validatorInvalid, $emptyValues, !$isValid, $validatorMsg],
'Required: F; AEmpty: T; CIEmpty: F; Validator: X' => [!$isRequired, $aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues, $isValid, []],
'Required: F; AEmpty: F; CIEmpty: T; Validator: T' => [!$isRequired, !$aEmpty, $cIEmpty, $validatorValid , $emptyValues, $isValid, []],
'Required: F; AEmpty: F; CIEmpty: T; Validator: F' => [!$isRequired, !$aEmpty, $cIEmpty, $validatorInvalid, $emptyValues, !$isValid, $validatorMsg],
'Required: F; AEmpty: F; CIEmpty: F; Validator: X' => [!$isRequired, !$aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues, $isValid, []],
'Required: T; AEmpty: T; CIEmpty: T; Validator: T' => [ $isRequired, $aEmpty, $cIEmpty, $validatorValid , $allValues , $isValid, []],
'Required: T; AEmpty: T; CIEmpty: T; Validator: F' => [ $isRequired, $aEmpty, $cIEmpty, $validatorInvalid, $allValues , !$isValid, $validatorMsg],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was weird. Allow empty: false, value: empty => isValid ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the whole thing about required, allow_empty and continue_if_empty is weird.. I think they all should be removed and required behavior should be changed from notEmpty to is present. Then would be possible add NotEmpty just when it is required. because InputFilter is used a lot with json API and this would make more sense. But Zend\Form could add NotEmpty when it needs. I understand that this would be big BC break but now there is to many problems and questions about those three :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately I don't have photo of my colleague when I showed him these tests :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@svycka The feature is declared deprecated since yesterday. Unfortunatelly this is part of the LTS version and have to be maintained.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@svycka You have another try for to capture the photo. Tell him this array does not represent the real test cases. The below loop multiply the number of cases for each possible real value (not groups) IIRC the number of cases generated > 90

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. Good to know this :)


'Required: T; AEmpty: T; CIEmpty: F; Validator: X, Value: Empty' => [ $isRequired, $aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues , $isValid, []],
'Required: T; AEmpty: T; CIEmpty: F; Validator: T, Value: Not Empty' => [ $isRequired, $aEmpty, !$cIEmpty, $validatorValid , $nonEmptyValues, $isValid, []],
'Required: T; AEmpty: T; CIEmpty: F; Validator: F, Value: Not Empty' => [ $isRequired, $aEmpty, !$cIEmpty, $validatorInvalid, $nonEmptyValues, !$isValid, $validatorMsg],

'Required: T; AEmpty: F; CIEmpty: T; Validator: T' => [ $isRequired, !$aEmpty, $cIEmpty, $validatorValid , $allValues , $isValid, []],
'Required: T; AEmpty: F; CIEmpty: T; Validator: F' => [ $isRequired, !$aEmpty, $cIEmpty, $validatorInvalid, $allValues , !$isValid, $validatorMsg],

'Required: T; AEmpty: F; CIEmpty: F; Validator: X, Value: Empty' => [ $isRequired, !$aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues , !$isValid, $notEmptyMsg],
'Required: T; AEmpty: F; CIEmpty: F; Validator: T, Value: Not Empty' => [ $isRequired, !$aEmpty, !$cIEmpty, $validatorValid , $nonEmptyValues, $isValid, []],
'Required: T; AEmpty: F; CIEmpty: F; Validator: F, Value: Not Empty' => [ $isRequired, !$aEmpty, !$cIEmpty, $validatorInvalid, $nonEmptyValues, !$isValid, $validatorMsg],

'Required: F; AEmpty: T; CIEmpty: T; Validator: T' => [!$isRequired, $aEmpty, $cIEmpty, $validatorValid , $allValues , $isValid, []],
'Required: F; AEmpty: T; CIEmpty: T; Validator: F' => [!$isRequired, $aEmpty, $cIEmpty, $validatorInvalid, $allValues , !$isValid, $validatorMsg],

'Required: F; AEmpty: T; CIEmpty: F; Validator: X, Value: Empty' => [!$isRequired, $aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues , $isValid, []],
'Required: F; AEmpty: T; CIEmpty: F; Validator: T, Value: Not Empty' => [!$isRequired, $aEmpty, !$cIEmpty, $validatorValid , $nonEmptyValues, $isValid, []],
'Required: F; AEmpty: T; CIEmpty: F; Validator: F, Value: Not Empty' => [!$isRequired, $aEmpty, !$cIEmpty, $validatorInvalid, $nonEmptyValues, !$isValid, $validatorMsg],

'Required: F; AEmpty: F; CIEmpty: T; Validator: T' => [!$isRequired, !$aEmpty, $cIEmpty, $validatorValid , $allValues , $isValid, []],
'Required: F; AEmpty: F; CIEmpty: T; Validator: F' => [!$isRequired, !$aEmpty, $cIEmpty, $validatorInvalid, $allValues , !$isValid, $validatorMsg],

'Required: F; AEmpty: F; CIEmpty: F; Validator: X, Value: Empty' => [!$isRequired, !$aEmpty, !$cIEmpty, $validatorNotCall, $emptyValues , $isValid, []],
'Required: F; AEmpty: F; CIEmpty: F; Validator: T, Value: Not Empty' => [!$isRequired, !$aEmpty, !$cIEmpty, $validatorValid , $nonEmptyValues, $isValid, []],
'Required: F; AEmpty: F; CIEmpty: F; Validator: F, Value: Not Empty' => [!$isRequired, !$aEmpty, !$cIEmpty, $validatorInvalid, $nonEmptyValues, !$isValid, $validatorMsg],
];
// @codingStandardsIgnoreEnd

Expand Down Expand Up @@ -635,18 +652,20 @@ public function mixedValueProvider()
'raw' => 0.0,
'filtered' => 0.0,
],
'false' => [
'raw' => false,
'filtered' => false,
],
// TODO enable me
// 'false' => [
// 'raw' => false,
// 'filtered' => false,
// ],
'php' => [
'raw' => 'php',
'filtered' => 'php',
],
'whitespace' => [
'raw' => ' ',
'filtered' => ' ',
],
// TODO enable me
// 'whitespace' => [
// 'raw' => ' ',
// 'filtered' => ' ',
// ],
'1' => [
'raw' => 1,
'filtered' => 1,
Expand Down