Fix for running with unit tests
-
I’m running some WordPress unit tests and get the error (using v3.3.3):
PHP Fatal error: Call to a member function add_shortcode() on a non-object in /var/www/projects/wordpress/wp-content/plugins/contact-form-7/includes/shortcodes.php on line 174
This is because PHPUnit doesn’t run WordPress in the global scope and
wpcf7_shortcode_manager
is expected to be defined globally. This can be fixed by explicitly declaring the variable in the global scope, changing line 169 to:$GLOBALS['wpcf7_shortcode_manager'] = new WPCF7_ShortcodeManager();
Whilst this probably isn’t a common problem, it’s a simple fix so it’d be great to see it in the code.
Thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Fix for running with unit tests’ is closed to new replies.