-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #22: "ComposedObject" Annotation does not add inputSpec to element configuration #207
Conversation
Signed-off-by: Raul Robledo <riul88@gmail.com>
Signed-off-by: Raul Robledo <riul88@gmail.com>
Signed-off-by: Raul Robledo <riul88@gmail.com>
$usernameInput = $composed->get('username'); | ||
self::assertInstanceOf(Input::class, $usernameInput); | ||
$validatorChain = $usernameInput->getValidatorChain(); | ||
self::assertInstanceOf(ValidatorChain::class, $validatorChain); | ||
$usernameValidators = $validatorChain->getValidators(); | ||
self::assertCount(2, $usernameValidators); | ||
self::assertInstanceOf(NotEmpty::class, $usernameValidators[0]['instance']); | ||
self::assertInstanceOf(StringLength::class, $usernameValidators[1]['instance']); | ||
$usernameFilters = $usernameInput->getFilterChain()->getFilters()->toArray(); | ||
self::assertCount(1, $usernameFilters); | ||
self::assertInstanceOf(StringTrim::class, $usernameFilters[0]); | ||
|
||
$passwordInput = $composed->get('password'); | ||
self::assertInstanceOf(Input::class, $passwordInput); | ||
$validatorChain = $passwordInput->getValidatorChain(); | ||
$passwordValidators = $validatorChain->getValidators(); | ||
self::assertCount(1, $passwordValidators); | ||
self::assertInstanceOf(EmailAddress::class, $passwordValidators[0]['instance']); | ||
|
||
$passwordFilters = $passwordInput->getFilterChain()->getFilters()->toArray(); | ||
self::assertCount(1, $passwordFilters); | ||
self::assertInstanceOf(StringTrim::class, $passwordFilters[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we split it out to a smaller test highlighting just what is being fixed? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the fix, username
and password
result indeed with no validator at all, wrongfully.
$usernameInput = $composed->get('username'); | ||
self::assertInstanceOf(Input::class, $usernameInput); | ||
$validatorChain = $usernameInput->getValidatorChain(); | ||
self::assertInstanceOf(ValidatorChain::class, $validatorChain); | ||
$usernameValidators = $validatorChain->getValidators(); | ||
self::assertCount(2, $usernameValidators); | ||
self::assertInstanceOf(NotEmpty::class, $usernameValidators[0]['instance']); | ||
self::assertInstanceOf(StringLength::class, $usernameValidators[1]['instance']); | ||
$usernameFilters = $usernameInput->getFilterChain()->getFilters()->toArray(); | ||
self::assertCount(1, $usernameFilters); | ||
self::assertInstanceOf(StringTrim::class, $usernameFilters[0]); | ||
|
||
$passwordInput = $composed->get('password'); | ||
self::assertInstanceOf(Input::class, $passwordInput); | ||
$validatorChain = $passwordInput->getValidatorChain(); | ||
$passwordValidators = $validatorChain->getValidators(); | ||
self::assertCount(1, $passwordValidators); | ||
self::assertInstanceOf(EmailAddress::class, $passwordValidators[0]['instance']); | ||
|
||
$passwordFilters = $passwordInput->getFilterChain()->getFilters()->toArray(); | ||
self::assertCount(1, $passwordFilters); | ||
self::assertInstanceOf(StringTrim::class, $passwordFilters[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the fix, username
and password
result indeed with no validator at all, wrongfully.
'name' => 'EmailAddress', | ||
], | ||
], | ||
], $passwordFilterSpec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test passes even without the fix though, but I like it has been added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
@Slamdunk Since you're official maintainer for this component now, I'll let you merge.
Thank you @riul88 |
Signed-off-by: Raul Robledo riul88@gmail.com
Description
Fix suggested by @weierophinney
Issue reproducible by unit test testAllowsComposingChildEntities but the test case didn't validate the filters or validators from the child entity, the unit test was updated as part of this PR to perform the missing assertions to ensure the element validators and filters are configured
The changes to unit test testAllowsComposingMultipleChildEntities which is used when ComposedObject is marked as isCollection are only preventive not impacted by the code change in the PR