Skip to content

Commit d18c238

Browse files
[PhpUnitBridge] Add enum_exists mock
1 parent a93dae9 commit d18c238

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

components/phpunit_bridge.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@ reason, this component also provides mocks for these PHP functions:
736736
* :phpfunction:`class_exists`
737737
* :phpfunction:`interface_exists`
738738
* :phpfunction:`trait_exists`
739+
* :phpfunction:`enum_exists`
739740

740741
Use Case
741742
~~~~~~~~
@@ -798,6 +799,16 @@ classes, interfaces and/or traits for the code to run::
798799
}
799800
}
800801

802+
Note that mocking a class with ``ClassExistsMock::withMockedClasses()``
803+
will make :phpfunction:`class_exists`, :phpfunction:`interface_exists`
804+
and :phpfunction:`trait_exists` return true.
805+
806+
To register an enumeration and mock :phpfunction:`enum_exists`,
807+
``ClassExistsMock::withMockedEnums()`` must be used. Note that, like in
808+
PHP 8.1 and later, calling ``class_exists`` on a enum will return ``true``.
809+
That's why calling ``ClassExistsMock::withMockedEnums()`` will also register the enum
810+
as a mocked class.
811+
801812
Troubleshooting
802813
---------------
803814

0 commit comments

Comments
 (0)