最合适的回答,由SO网友:J.D. 整理而成
错误告诉您,代码试图输出一个HTTP响应头header() 响应正文已开始发送后的函数。如您所述,第68行bootstrap.php 正在调用输出Installing.... 因此,在输出已经发送之后,您不能发送响应头。
调试的下一步是找出发送响应头的原因。这是不应该发生的,因为这里我们是从命令行运行测试,实际上我们并没有向浏览器发送页面。
所以,我们需要看看header() 正在调用。错误告诉您它在wp-load.php 第64行:
header( \'Location: \' . $path );
这条线本身并没有告诉我们太多,但我们发现它在一个大范围内
if ... else 声明:
/*
* If wp-config.php exists in the WordPress root, or if it exists in the root and wp-settings.php
* doesn\'t, load wp-config.php. The secondary check for wp-settings.php has the added benefit
* of avoiding cases where the current directory is a nested installation, e.g. / is WordPress(a)
* and /blog/ is WordPress(b).
*
* If neither set of conditions is true, initiate loading the setup process.
*/
if ( file_exists( ABSPATH . \'wp-config.php\') ) {
/** The config file resides in ABSPATH */
require_once( ABSPATH . \'wp-config.php\' );
} elseif ( @file_exists( dirname( ABSPATH ) . \'/wp-config.php\' ) && ! @file_exists( dirname( ABSPATH ) . \'/wp-settings.php\' ) ) {
/** The config file resides one level above ABSPATH but is not part of another install */
require_once( dirname( ABSPATH ) . \'/wp-config.php\' );
} else {
// snip
header( \'Location: \' . $path );
// snip
}
基本上这告诉我们
wp-load.php 正在寻找
wp-config.php 文件,但找不到它。因此,它正在启动设置过程,并且作为该过程的一部分,它试图通过发送
Location 标题。
所以你显然没有设置wp-config.php 正确归档。
这个wp-config.php 文件应该是由您运行的脚本设置的,所以这很可能是某种失败的指示。事实上,由于我们在这里运行测试wp-tests-config.php 应改用文件。所以下一步就是找出原因wp-tests-config.php 未加载。你应该可以在/tmp/wordpress-tests-lib/ 目录