使用Drupal6和SimpleTest无法在测试用例中进行SimpleTest GET和POST

时间:2013-05-08 08:44:31

标签: php unit-testing curl drupal-6 simpletest

一段时间后我运行了这个示例测试,Drupal批处理屏幕(带有进度条的屏幕)停止运行,我的服务器日志中没有记录错误,整个浏览器窗口保持冻结状态。代码非常基础:

<?php
class FooTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'test',
      'description' => 'test',
      'group' => 'Foo',
    );
  }

  public function setUp() {
    parent::setUp();
  }

  public function testLogin() {
    // The drupalCreateUser() runs fine
    $user = $this->drupalCreateUser(array('access content'));
    // If i comment out the following, test runs fine.
    $this->drupalLogin($user);
  }
}
?>

我缺少什么?

== EDIT1 ==

另外一条线索:我通过drush test-run运行测试,它们工作正常。

== EDIT2 ==

结果是curl_setopt_array错误,它在DrupalWebTestCase::curlInitialize()期间返回FALSE。这个问题没有进一步的进展。

== EDIT3 ==

经过深度调试后,这成了卷曲CURLOPT_FOLLOWLOCATION的一个问题,它会在设置尝试时触发错误。

1 个答案:

答案 0 :(得分:1)

如果在您的php配置中

,CURLOPT_FOLLOWLOCATION将无效
  • safe_mode =开启
  • 设置了open_basedir

因此,更改其中一个或两个应该可以解决问题。有3个地方可以实现这一目标。

php.ini safe_mode =关闭,并注释掉open_basedir

apache .conf .htaccess

php_value safe_mode Off
php_value open_basedir none

请注意,您的服务器配置必须允许覆盖值才能使用.htaccess。

另请注意,CURLOPT_FOLLOWLOCATION自php 5.3起已被弃用,并已在php 5.4中删除。