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

Skip to content

[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

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Dec 8, 2022

@carsonbot carsonbot added this to the 6.3 milestone Dec 8, 2022
@carsonbot carsonbot changed the title [PhpUnitBridge] Add enum_exists mock [PHPUnitBridge] Add enum_exists mock Dec 8, 2022
@OskarStark OskarStark added the Waiting Code Merge Docs for features pending to be merged label Dec 8, 2022
@carsonbot carsonbot modified the milestones: 6.3, next Dec 8, 2022
@ro0NL
Copy link
Contributor

ro0NL commented Dec 20, 2022

a combination of withMockedClasses + withMockedEnums should be explained IMHO (symfony/symfony#48516 (comment))

@alexandre-daubois
Copy link
Member Author

@ro0NL the doc was actually written before adding withMockedEnums. I think it worth updating this, good idea! I'll have a look

@ro0NL
Copy link
Contributor

ro0NL commented Dec 20, 2022

while at it, we should probably mention mocking a class (symbol) means all *_exists() functions return true

except enums, hence mockWithEnum

@alexandre-daubois
Copy link
Member Author

Updated, @javiereguiluz please tell me if I need to rephrase anything! 🙂

and :phpfunction:`trait_exists` return true.

To register an enumeration and mock :phpfunction:`enum_exists`,
``ClassExistsMock::withMockedEnums()`` must be used.
Copy link
Contributor

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)) {

nicolas-grekas added a commit to symfony/symfony that referenced this pull request Jan 9, 2023
…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
@OskarStark OskarStark removed the Waiting Code Merge Docs for features pending to be merged label Jan 10, 2023
@OskarStark
Copy link
Contributor

@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

@alexandre-daubois
Copy link
Member Author

@OskarStark I updated the documentation! 🙂

@OskarStark
Copy link
Contributor

Thanks Alexandre.

@OskarStark OskarStark merged commit ca16ef8 into symfony:6.3 Jan 10, 2023
@alexandre-daubois alexandre-daubois deleted the feat/enum_exists branch January 10, 2023 13:23
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