Skip to content
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

Merged
merged 3 commits into from
Mar 13, 2023

Conversation

riul88
Copy link
Contributor

@riul88 riul88 commented Mar 11, 2023

Signed-off-by: Raul Robledo riul88@gmail.com

Q A
Documentation no
Bugfix yes
BC Break yes/no
New Feature no
RFC yes/no
QA yes/no

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

riul88 added 3 commits March 10, 2023 20:43
Signed-off-by: Raul Robledo <riul88@gmail.com>
Signed-off-by: Raul Robledo <riul88@gmail.com>
Signed-off-by: Raul Robledo <riul88@gmail.com>
Comment on lines +224 to +245
$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]);
Copy link
Member

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? 🤔

Copy link
Contributor

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.

@froschdesign froschdesign changed the title hotfix/22 Fixes #22: "ComposedObject" Annotation does not add inputSpec to element configuration Mar 13, 2023
@froschdesign froschdesign added Bug Something isn't working Awaiting Author Updates labels Mar 13, 2023
@froschdesign froschdesign requested a review from Slamdunk March 13, 2023 09:14
Comment on lines +224 to +245
$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]);
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Member

@weierophinney weierophinney left a 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.

@Slamdunk Slamdunk added this to the 3.8.1 milestone Mar 13, 2023
@Slamdunk Slamdunk merged commit 843056a into laminas:3.9.x Mar 13, 2023
@Slamdunk
Copy link
Contributor

Thank you @riul88

@Slamdunk Slamdunk modified the milestones: 3.8.1, 3.9.0 Mar 13, 2023
@riul88 riul88 deleted the hotfix/22 branch March 14, 2023 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"ComposedObject" Annotation does not add inputSpec to element configuration
5 participants