-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[PHPUnitBridge] Add enum_exists
mock
#17538
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
Conversation
enum_exists
mockenum_exists
mock
a combination of withMockedClasses + withMockedEnums should be explained IMHO (symfony/symfony#48516 (comment)) |
@ro0NL the doc was actually written before adding |
while at it, we should probably mention mocking a class (symbol) means all *_exists() functions return true except enums, hence mockWithEnum |
6771d45
to
002d4fc
Compare
Updated, @javiereguiluz please tell me if I need to rephrase anything! 🙂 |
components/phpunit_bridge.rst
Outdated
and :phpfunction:`trait_exists` return true. | ||
|
||
To register an enumeration and mock :phpfunction:`enum_exists`, | ||
``ClassExistsMock::withMockedEnums()`` must be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps it's obvious for ppl, but only yesteday i realized class_exists returns true for enums (symfony/symfony#48516 (comment))
so what this new method enables doing is:
withMockedClasses([SomeClass::class => true])
withMockedEnums([SomeClass::class => false])
to trigger a code path for if (class_exists(SomeClass::class) && !enum_exists(SomeClass::class)) {
…ois) This PR was merged into the 6.3 branch. Discussion ---------- [PhpUnitBridge] Add `enum_exists` mock | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | _N/A_ | License | MIT | Doc PR | symfony/symfony-docs#17538 Commits ------- 8d3e897 [PhpUnitBridge] Add `enum_exists` mock
@alexandre-daubois can you please check if this PR is up-to-date with the latest work in the code PR? Please ping me afterwards, so I can merge it, thanks |
002d4fc
to
d18c238
Compare
@OskarStark I updated the documentation! 🙂 |
Thanks Alexandre. |
Related to symfony/symfony#48516