we've got a custom website that uses Laravel for the frontend / backend and then we load Wordpress to handle all of the CMS stuff, so some templates for example call wordpress plugin functions and so on.
We include wordpress using the following in public/index.php:
define('WP_USE_THEMES', false);
require __DIR__.'/cms/wp-load.php';
function header_func($headers, $wp) {
return array();
}
add_filter( 'wp_headers', 'header_func', 99, 2 );
date_default_timezone_set ('Australia/Melbourne');
//Remove all slashes added by wordpress
$_POST = array_map( 'stripslashes_deep', $_POST );
$_GET = array_map( 'stripslashes_deep', $_GET );
$_COOKIE = array_map( 'stripslashes_deep', $_COOKIE );
$_REQUEST = array_map( 'stripslashes_deep', $_REQUEST );
So that all works great, but using Laravel 5.1 we're trying to setup some unit testing to test the pages but every time I try I get the error: "Fatal error: Class 'WP_Query' not found in ..."
Which almost seems like its not loading the public/index.php at all but instead loading the page through code. It skips the /public/index.php entirely, so wordpress isn't loaded. I tried including the code to load wordpress inside the unit test, but Wordpress doesn't appear to load the plugins or theme (perhaps its waiting for an actual request?) so it starts throwing other errors about missing plugin functions.
So calls like $response = $this->call('GET', '/'); fail to run.
This did work in Laravel 5.0, but it doesn't seem to work in 5.1. Does anyone know what changed and if its possible to get this working again?
Cheers!
Aucun commentaire:
Enregistrer un commentaire