我是phpunit的新手。我想用它在drupal(drupal.org) 我的测试文件名为functional_test的文件夹中,该文件夹位于网站的根目录 中。如果希望看到完整的目录结构,那么 看到在这里http://pastebin.com/TaqGLq8uPHP致命错误:调用未定义的函数content_try()
然而,当我运行它,我得到的错误:
PHP致命错误:在/ home调用未定义功能content_try()/维沙尔/ Dropbox的/网站/ drupal_test/functional_test/index_Test.php上线23
我肯定的index.php是越来越发现作为你可以看到完整的输出 这里http://pastebin.com/FVkn2ig1
另外,如果我把测试文件外r中的功能目录OOT目录它的工作原理
我的测试代码很简单:
require_once '../index.php';
class index_Test extends PHPUnit_Framework_TestCase
{
public function test_content_try()
{
$value=content_try();
$this->assertEquals('1', $value,'Value should be one');
}
}
,我想测试我的index.php文件是:
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler();
function content_try()
{
return 1;
}
我不清楚我可能会做这里错了。
我对php一无所知,但我的猜测会是content_try的一个“公开”缺少的内容 – npst
了解变量作用域。 将'require_once'../ index.php';'移动到测试方法 – kryoz
@npst public没有这样做。 –