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 running tests for autoloaded classes #1327

Closed
wants to merge 4 commits into from

Conversation

dracony
Copy link
Contributor

@dracony dracony commented Jul 9, 2014

Should fix this issue: #529

This will always perform the check for $suiteClassName inside loaded classes

@aik099
Copy link

aik099 commented Jul 9, 2014

Tests failed. Not sure if they were passing before this code change.

Also please add a test to prove that it really works.

@whatthejeff
Copy link
Contributor

Too fast, @aik099! I was just typing exactly that ;)

PS: The tests were indeed passing before the change.

@dracony
Copy link
Contributor Author

dracony commented Jul 9, 2014

They pass now =)

@whatthejeff
Copy link
Contributor

@dracony Would you mind adding new tests for the bug this PR fixes?

@dracony
Copy link
Contributor Author

dracony commented Jul 16, 2014

Added tests. Please merge this as I really need this functionality to be finally working =P

thanks

@dracony
Copy link
Contributor Author

dracony commented Jul 23, 2014

Can this pleeeeeeease be merged now? I added tests, it basses build. Why does it take so looong?

@whatthejeff
Copy link
Contributor

@dracony Please be patient. Your PR has possible BC and performance implications that I need to investigate before I can merge it. I hope to have time this weekend, but no guarantees.

$baseName = str_replace('.php', '', basename($filename));

foreach ($newClasses as $className) {
foreach ($this->untestedClasses as $className) {
if (substr($className, 0 - strlen($baseName)) == $baseName) {
$class = new ReflectionClass($className);
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 you should remove classes that have been loaded from $untestedClasses, i.e. something like

foreach ($this->untestedClasses as $i => $className) {
    if (substr(...)) {
        ...
        unset($this->untestedClasses[$i]);
    }
}

@webmozart
Copy link
Contributor

I second this PR.

@whatthejeff
Copy link
Contributor

@dracony This looks great. Sorry it took me so long to get around to it. Would you mind opening a new PR that targets the 4.1 branch so that we could get this in the next stable release. Also, I think the suggestion from @webmozart makes sense. Would you mind incorporating that?

@dracony
Copy link
Contributor Author

dracony commented Jul 28, 2014

Done! Here is the pull request: #1362

@webmozart
Copy link
Contributor

@dracony In the future, I recommend to create separate branches for PRs (e.g. git checkout -b issue529). Then you can update and rebase that branch as you like. As soon as you push the updated branch, the existing PR is updated and you don't need to open new PRs. :)

webmozart added a commit to symfony/symfony that referenced this pull request Aug 4, 2014
…ebmozart)

This PR was squashed before being merged into the 2.5 branch (closes #11485).

Discussion
----------

[Validator] Constraint validators now use the 2.5 API

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

See the comments in #11049 for the origin of this PR.

Currently, the 2.5 API needs to use `LegacyExecutionContextFactory` because the constraint validators rely on methods from the old `ExecutionContext` class (like `validate()`, `validateValue()`). Consequently it is impossible to switch to the pure 2.5 API and check whether all calls to deprecated methods were removed from application code. This is fixed now.

This PR also introduces a complete test suite to test each constraint validator against all three APIs: 2.4, 2.5-BC and 2.5. Currently, some tests are not executed yet when running the complete test suite is run. I expect this to be fixed soon (ticket: sebastianbergmann/phpunit#529, pr: sebastianbergmann/phpunit#1327).

Commits
-------

295e5bb [Validator] Fixed failing tests
3bd6d80 [Validator] CS fixes
870a41a [FrameworkBundle] Made ConstraintValidatorFactory aware of the legacy validators
7504448 [Validator] Added extensive test coverage for the constraint validators for the different APIs
8e461af [Validator] Constraint validators now use the 2.5 API. For incompatible validators, legacy validators were created
symfony-splitter pushed a commit to symfony/validator that referenced this pull request Aug 4, 2014
…ebmozart)

This PR was squashed before being merged into the 2.5 branch (closes #11485).

Discussion
----------

[Validator] Constraint validators now use the 2.5 API

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

See the comments in #11049 for the origin of this PR.

Currently, the 2.5 API needs to use `LegacyExecutionContextFactory` because the constraint validators rely on methods from the old `ExecutionContext` class (like `validate()`, `validateValue()`). Consequently it is impossible to switch to the pure 2.5 API and check whether all calls to deprecated methods were removed from application code. This is fixed now.

This PR also introduces a complete test suite to test each constraint validator against all three APIs: 2.4, 2.5-BC and 2.5. Currently, some tests are not executed yet when running the complete test suite is run. I expect this to be fixed soon (ticket: sebastianbergmann/phpunit#529, pr: sebastianbergmann/phpunit#1327).

Commits
-------

295e5bb [Validator] Fixed failing tests
3bd6d80 [Validator] CS fixes
870a41a [FrameworkBundle] Made ConstraintValidatorFactory aware of the legacy validators
7504448 [Validator] Added extensive test coverage for the constraint validators for the different APIs
8e461af [Validator] Constraint validators now use the 2.5 API. For incompatible validators, legacy validators were created
fago pushed a commit to fago/Validator that referenced this pull request Apr 18, 2015
…ebmozart)

This PR was squashed before being merged into the 2.5 branch (closes #11485).

Discussion
----------

[Validator] Constraint validators now use the 2.5 API

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

See the comments in #11049 for the origin of this PR.

Currently, the 2.5 API needs to use `LegacyExecutionContextFactory` because the constraint validators rely on methods from the old `ExecutionContext` class (like `validate()`, `validateValue()`). Consequently it is impossible to switch to the pure 2.5 API and check whether all calls to deprecated methods were removed from application code. This is fixed now.

This PR also introduces a complete test suite to test each constraint validator against all three APIs: 2.4, 2.5-BC and 2.5. Currently, some tests are not executed yet when running the complete test suite is run. I expect this to be fixed soon (ticket: sebastianbergmann/phpunit#529, pr: sebastianbergmann/phpunit#1327).

Commits
-------

295e5bb [Validator] Fixed failing tests
3bd6d80 [Validator] CS fixes
870a41a [FrameworkBundle] Made ConstraintValidatorFactory aware of the legacy validators
7504448 [Validator] Added extensive test coverage for the constraint validators for the different APIs
8e461af [Validator] Constraint validators now use the 2.5 API. For incompatible validators, legacy validators were created
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants