From d18c23844c341a2cdb274477ac0a763f9507972c Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 8 Dec 2022 13:35:38 +0100 Subject: [PATCH] [PhpUnitBridge] Add `enum_exists` mock --- components/phpunit_bridge.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 8650153e378..068753f9461 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -736,6 +736,7 @@ reason, this component also provides mocks for these PHP functions: * :phpfunction:`class_exists` * :phpfunction:`interface_exists` * :phpfunction:`trait_exists` +* :phpfunction:`enum_exists` Use Case ~~~~~~~~ @@ -798,6 +799,16 @@ classes, interfaces and/or traits for the code to run:: } } +Note that mocking a class with ``ClassExistsMock::withMockedClasses()`` +will make :phpfunction:`class_exists`, :phpfunction:`interface_exists` +and :phpfunction:`trait_exists` return true. + +To register an enumeration and mock :phpfunction:`enum_exists`, +``ClassExistsMock::withMockedEnums()`` must be used. Note that, like in +PHP 8.1 and later, calling ``class_exists`` on a enum will return ``true``. +That's why calling ``ClassExistsMock::withMockedEnums()`` will also register the enum +as a mocked class. + Troubleshooting ---------------