Skip to content

Move Constraint validator test case to Test namespace #17203

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

Merged
merged 1 commit into from
Jun 15, 2016

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Dec 31, 2015

Q A
Bug fix? no
New feature? kinda
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

The Validator component has a very usefull test utility to test constraint validators. It's only hidden deep in the Tests namespace. Just as was done with the TypeTestCase of the Form component some years ago, I think it's usefull to move the constraint test case to the Test namespace as well.

Btw, my last PR of the year and the first deprecation of 3.1 🎆

$this->constraint,
$this->cause
);
trigger_error('The '.__NAMESPACE__.'/AbstractConstraintValidatorTest is deprecated since version 3.1 and will be removed in 3.0. Use Symfony\Component\Validator\Test\ConstraintValidatorTestCase instead.', E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

missing silencing

Copy link
Member

Choose a reason for hiding this comment

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

and it cannot be removed in 3.0...

@wouterj wouterj force-pushed the validator-move_constraint_test branch from 30ea9a3 to cbf1f77 Compare December 31, 2015 17:29
@wouterj
Copy link
Member Author

wouterj commented Dec 31, 2015

Thanks for your quick review, @stof! I've fixed the PR now.

@Tobion
Copy link
Contributor

Tobion commented Jan 12, 2016

We do not maintain BC for test files in Tests namespace. So these deprecations are not needed.

@nicolas-grekas
Copy link
Member

I agree with @Tobion, no need to preserve BC for tests
Status: needs work

@stof
Copy link
Member

stof commented Jan 13, 2016

Well, given that some tests are using this class in other components, we would have to preserve BC (and people might use it elsewhere too already). The point is that this base testcase is meant to be extended when writing tests. We just messed up its location when introducing it (and this is the drawback of the inclusion of tests inside the runtime, as our testsuite is autoloadable by any code installing the component as a dependency)
We were maintaining BC for similar base testcases in the Form component in 2.x

@@ -28,7 +28,7 @@
"symfony/property-info": "~2.8|3.0",
"symfony/security": "~2.8|~3.0",
"symfony/expression-language": "~2.8|~3.0",
"symfony/validator": "~2.8|~3.0",
"symfony/validator": "~3.1",
Copy link
Member

Choose a reason for hiding this comment

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

This is an issue: we won't test the bridge with symfony/validator anymore, which could hide BC breaks.
We need to find a way to keep ~2.8 here.
(same comment for the other cases below)

Copy link
Member Author

Choose a reason for hiding this comment

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

Why wouldn't this test the bridge with symfony/validator anymore? It would simply be tested against 3.1, or am I missing something?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@nicolas-grekas Can you give us more insights about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the point is that the test suite tests both against the highest and lowest possible dependencies. Since 3.1 is the minimum boundary, even the --prefer-lowest tests will run against 3.1 and not against 2.8, which might hide compatibility issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

So the solution would be to keep both classes (new and old) and use the old one in the core libraries, so we can still properly support and test 2.8 and 3.0?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that would be good, yes.

@nicolas-grekas
Copy link
Member

@stof, then I suggest to NOT deprecate anything in this PR

@stof
Copy link
Member

stof commented Jan 13, 2016

@nicolas-grekas I don't understand what you mean. Do you suggest moving the class without deprecating the old class name ?

@nicolas-grekas
Copy link
Member

@stof yes, that's the best idea I have for now to still allow ~2.8 in composer json files...

@fabpot
Copy link
Member

fabpot commented Jan 25, 2016

I think we are going too far with BC. Files under Tests are internal and private. Let's move the file and not care about BC here.

@wouterj wouterj force-pushed the validator-move_constraint_test branch from cbf1f77 to 5c516d8 Compare January 25, 2016 14:10
@wouterj
Copy link
Member Author

wouterj commented Jan 25, 2016

Alright, removed the class and file.

@fabpot
Copy link
Member

fabpot commented Feb 29, 2016

@nicolas-grekas The only remaining issue is the composer deps changes
@wouterj Can you rebase?

@wouterj wouterj force-pushed the validator-move_constraint_test branch from 5c516d8 to 5eeb754 Compare February 29, 2016 19:14
@wouterj
Copy link
Member Author

wouterj commented Feb 29, 2016

Rebased

Status: Needs review

@@ -1,6 +1,7 @@
UPGRADE FROM 3.0 to 3.1
=======================

<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

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

Conflict resolution issue

@wouterj wouterj force-pushed the validator-move_constraint_test branch from 5eeb754 to d4ff6ff Compare February 29, 2016 20:04
@wouterj
Copy link
Member Author

wouterj commented Feb 29, 2016

Thanks, fixed your comments @stof.

@xabbuh
Copy link
Member

xabbuh commented Mar 1, 2016

This seems to need a rebase again.

// ...
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;

class MyCustomValidatorTest extends ConstraintValidatorTestCase
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we move away from prefixing abstract classes with Abstract (in general)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I'm not sure actually. But it seems to be more common to not add the prefix for abstract classes in Symfony.

@fabpot
Copy link
Member

fabpot commented Jun 15, 2016

@wouterj IIUC, it would be better to keep AbstractConstraintValidatorTest.php for now along side the new one and keep 2.8 as the min requirement. Is that correct @nicolas-grekas? If yes, let's do this and merge.

@wouterj wouterj force-pushed the validator-move_constraint_test branch from d4ff6ff to ed33a2d Compare June 15, 2016 09:42
@wouterj
Copy link
Member Author

wouterj commented Jun 15, 2016

Updated the PR to keep both classes and deprecate the old one. We can't trigger a deprecation warning, as we can't update all core packages to use the new class.

@wouterj wouterj force-pushed the validator-move_constraint_test branch from ed33a2d to 0e868ee Compare June 15, 2016 09:44
@wouterj wouterj force-pushed the validator-move_constraint_test branch from 0e868ee to e938361 Compare June 15, 2016 14:32
@fabpot
Copy link
Member

fabpot commented Jun 15, 2016

Thank you @wouterj.

@fabpot fabpot merged commit e938361 into symfony:master Jun 15, 2016
fabpot added a commit that referenced this pull request Jun 15, 2016
…(WouterJ)

This PR was merged into the 3.2-dev branch.

Discussion
----------

Move Constraint validator test case to Test namespace

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | kinda
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

The Validator component has a very usefull test utility to test constraint validators. It's only hidden deep in the Tests namespace. Just as was done with the TypeTestCase of the Form component some years ago, I think it's usefull to move the constraint test case to the Test namespace as well.

*Btw, my last PR of the year and the first deprecation of 3.1* 🎆

Commits
-------

e938361 Move Constraint validator test case to Test namespace
@wouterj wouterj deleted the validator-move_constraint_test branch June 15, 2016 21:42
@fabpot fabpot mentioned this pull request Oct 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants