You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to set up a test environment for a WordPress plugin using Brain\Monkey, I'm encountering a ReflectionException stating that the get_option() function does not exist. This occurs during the bootstrap process, specifically when Patchwork tries to patch WordPress functions.
Error in bootstrap script: ReflectionException:
Function get_option() does not exist
#0 C:\xampp\htdocs\wordpress\wp-content\plugins\zarzadzanie-dzielnicami\vendor\antecedent\patchwork\src\CallRerouting.php(416): ReflectionFunction->__construct('get_option')
#1 C:\xampp\htdocs\wordpress\wp-content\plugins\zarzadzanie-dzielnicami\vendor\antecedent\patchwork\Patchwork.php(131): Patchwork\CallRerouting\createStubsForInternals()
#2 C:\xampp\htdocs\wordpress\wp-content\plugins\zarzadzanie-dzielnicami\tests\bootstrap.php(4): require_once('C:\\xampp\\htdocs...')`
What I've Tried
Loading Patchwork before any function definitions
Using different namespace approaches (global namespace, namespaced code)
Manually defining WordPress functions before Brain\Monkey setup
Using Brain\Monkey's Functions\stubs() instead of manual function definitions
Following the solution from this StackOverflow post
Expected Behavior
The test bootstrap should successfully mock WordPress functions using Brain\Monkey without throwing the ReflectionException.
Question
Is there a specific order or approach required to properly set up Brain\Monkey with Patchwork for WordPress function mocking? The documentation suggests this should work, but I'm encountering this error consistently.
The text was updated successfully, but these errors were encountered:
Description
When trying to set up a test environment for a WordPress plugin using Brain\Monkey, I'm encountering a
ReflectionException
stating that the get_option() function does not exist. This occurs during the bootstrap process, specifically when Patchwork tries to patch WordPress functions.Environment
Dependencies (from composer.json)
Bootstrap :
Error Log
What I've Tried
Loading Patchwork before any function definitions
Using different namespace approaches (global namespace, namespaced code)
Manually defining WordPress functions before Brain\Monkey setup
Using Brain\Monkey's Functions\stubs() instead of manual function definitions
Following the solution from this StackOverflow post
Expected Behavior
The test bootstrap should successfully mock WordPress functions using Brain\Monkey without throwing the ReflectionException.
Question
Is there a specific order or approach required to properly set up Brain\Monkey with Patchwork for WordPress function mocking? The documentation suggests this should work, but I'm encountering this error consistently.
The text was updated successfully, but these errors were encountered: