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

Fix deprecated ValidatorInterface usage #491

Closed

Conversation

soullivaneuh
Copy link
Contributor

Fixes #438.

ping @stof for review.

@schmittjoh: In which configuration file this service is configured?

@stof
Copy link
Contributor

stof commented Sep 9, 2015

In which configuration file this service is configured?

not needed. The service id does not change. there is nothing to configure

throw new \InvalidArgumentException('Argument 1 of '.__METHOD__.' must be an instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface.');
}

if ($validator instanceof LegacyValidatorInterface) {
Copy link
Contributor

Choose a reason for hiding this comment

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

check for !$validator instanceof ValidatorInterface instead. Otherwise you will get the deprecation warning all the time (the class implements both interfaces in Symfony for BC reasons)

@stof
Copy link
Contributor

stof commented Sep 9, 2015

you should add tests for this class

@soullivaneuh soullivaneuh force-pushed the deprecate-validator branch 2 times, most recently from 4f76cf0 to b8a5d44 Compare September 9, 2015 13:52
@soullivaneuh
Copy link
Contributor Author

you should add tests for this class

I agree, but tests are already failing on master. BTW, Travis should be set up.

@schmittjoh What should I do for this?

@stof
Copy link
Contributor

stof commented Sep 14, 2015

@soullivaneuh Travis is running. It is just unable to set the commit status. See #495

@soullivaneuh
Copy link
Contributor Author

@stof yes, and as you can see, test are already failing: https://travis-ci.org/schmittjoh/serializer/builds/80216387

They need to be fixed before writing my own.

@stof
Copy link
Contributor

stof commented Sep 14, 2015

@soullivaneuh this does not prevent writing new tests for these class, which would be passing (only 2 tests are failing in the testsuite, not the whole testsuite)

@soullivaneuh
Copy link
Contributor Author

Ideed. Was thinking travis broke before ending all the test. Seems not.

@soullivaneuh
Copy link
Contributor Author

@stof @schmittjoh done.

@stof
Copy link
Contributor

stof commented Sep 14, 2015

@soullivaneuh this is not actually testing the BC layer: the only way to test it is to force installing an old Symfony version.
You should have tests using always the old API (marked as @group legacy, and skipped when the deprecated API is not available, to make the testsuite ready for Symfony 3 support) and tests using always the new API (and skipped on old Symfony Validator versions when the interface is not available)

@soullivaneuh
Copy link
Contributor Author

Okay @stof, it would be better to copy the class and make it legacy.

@stof
Copy link
Contributor

stof commented Sep 14, 2015

well, you could indeed have 2 test cases rather than having 2 series of tests in the same testcase, but it would make it harder to notice that we have 2 series of tests for someone editing tests of the class later

@soullivaneuh
Copy link
Contributor Author

2 series of tests for someone editing tests of the class later

Note sure if we should update legacy tests in this case.

Done for double test cases.

@stof
Copy link
Contributor

stof commented Sep 14, 2015

Note sure if we should update legacy tests in this case.

IMO we should: the tests are there to ensure that the feature works fine against both APIs, to ensure compatibility with Symfony 2.3 too

@soullivaneuh
Copy link
Contributor Author

@stof Thinking of your words:

this is not actually testing the BC layer: the only way to test it is to force installing an old Symfony version.

Actually, with a single class like I did before, both will be tested if Travis is correctly configured with different symfony versions AND lowest deps.

@stof
Copy link
Contributor

stof commented Sep 14, 2015

@soullivaneuh but not locally, making it easier to miss it. and it would also be a pain to configure tests as legacy, as your test would be tested the legacy case only in some environments but not in others

@soullivaneuh
Copy link
Contributor Author

as your test would be tested the legacy case only in some environments but not in others

I don't think it's needed too. We are testing our usage case, not if legacy ValidatorInterface works well on any Symfony version. It's a job for Symfony mainteners, isn't it?

BTW, actually it's spitted onto two classes, should be ok now.

@stof
Copy link
Contributor

stof commented Sep 14, 2015

@soullivaneuh we are testing whether the serializer code works againt both interfaces, which is the job of the serializer library.

Symfony maintainers cannot check whether the interface works btw: an interface never works as it has no implementation for its methods. You can only write tests for concrete code, not for interfaces. Tests are covering the implementation.

@soullivaneuh
Copy link
Contributor Author

an interface never works as it has no implementation for its methods.

A agree, but we are taking an interface as an argument, not writing one. Am I wrong?

@stof
Copy link
Contributor

stof commented Sep 14, 2015

@soullivaneuh you are writing code against 2 different interfaces. So you should have tests covering both. This is why I vote for having a testsuite using both interfaces when they are both available, rather than only the newer one.

@soullivaneuh
Copy link
Contributor Author

Okay, that is done so.

@goetas
Copy link
Collaborator

goetas commented Aug 4, 2016

Is this still valid? if not i'm going to close it in some weeks

@goetas
Copy link
Collaborator

goetas commented Dec 5, 2016

replaced by #491

@goetas goetas closed this Dec 5, 2016
@soullivaneuh soullivaneuh deleted the deprecate-validator branch June 26, 2017 08:43
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.

3 participants