Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[PhpUnitBridge] Added ClassExistsMock #28931

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
Dec 10, 2018
Merged

[PhpUnitBridge] Added ClassExistsMock #28931

merged 1 commit into from
Dec 10, 2018

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Oct 20, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #...
License MIT
Doc PR symfony/symfony-docs#10528

I've thought about this before, and bumped into it again when trying to test #28898

This PR allows to mock class|interface|trait_exists to enable specific code path testing

@nicolas-grekas
Copy link
Member

Mocks don't work with root-namespaced functions, and it turns out that *_exists() are in the list of the calls we recommend root-aliasing... Which means this will have a very low reach. For this reason, I'm not sure we should maintain this...

@ro0NL
Copy link
Contributor Author

ro0NL commented Oct 20, 2018

ouch :( i didnt saw any root namespaced variant in code base. Also CS does not propose these functions (yet) right?

@nicolas-grekas
Copy link
Member

Actually I was wrong sorry, *_exists() are not in the list!

@nicolas-grekas nicolas-grekas added this to the next milestone Oct 20, 2018
@ro0NL ro0NL mentioned this pull request Oct 20, 2018
@ro0NL ro0NL changed the title [PhpUnitBridge] Added SymbolExistenceMock [PhpUnitBridge] Added ClassExistsMock Oct 21, 2018
@javiereguiluz
Copy link
Member

@ro0NL thanks for creating symfony/symfony-docs#10528 to track this feature in Symfony Docs. Much appreciated!

Sadly, the docs issue is not very actionable because the description of this PR is a bit lacking. Please update it to explain which changes would this require for full Symfony apps and for apps that use this as a stand-alone component.

If no changes are needed, please add some before/after examples or show what can we do now that wasn't possible before. Thanks!

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 1, 2018

should there be any annotation integration, ie. @class-exists Some\Class Some\Other\Class?

@nicolas-grekas
Copy link
Member

I'm not sure - not if we don't have a use case.

@ro0NL
Copy link
Contributor Author

ro0NL commented Dec 1, 2018

#28898 could have one more test using @class-not-exists Symfony\Component\VarDumper\Dumper\CliDumper 👼

@fabpot
Copy link
Member

fabpot commented Dec 10, 2018

Thank you @ro0NL.

@fabpot fabpot merged commit 62caec1 into symfony:master Dec 10, 2018
fabpot added a commit that referenced this pull request Dec 10, 2018
This PR was squashed before being merged into the 4.3-dev branch (closes #28931).

Discussion
----------

[PhpUnitBridge] Added ClassExistsMock

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#10528

I've thought about this before, and bumped into it again when trying to test #28898

This PR allows to mock `class|interface|trait_exists` to enable specific code path testing

Commits
-------

62caec1 [PhpUnitBridge] Added ClassExistsMock
@ro0NL ro0NL deleted the symbol-mock branch December 10, 2018 08:12
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
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.

5 participants