Drupal的SimpleTest不能创建自定义表的副本

时间:2009-09-03 00:20:19

标签: drupal simpletest

我正在使用SimpleTest模块版本6.x-2.8和Drupal 6.13。我写了一个自定义模块,为此我写了一些测试。但是,SimpleTest似乎没有创建与我的自定义模块关联的表的副本,因为每次我尝试在表中插入某些内容或在SimpleTest中查询它时都会收到异常消息。

在SimpleTest结果页面中,所有插入查询都会产生类似的结果: 表'db_name.simpletest692319new_table'不存在查询:INSERT INTO simpletest692319new_table(...)

我的.install文件中为模块定义了一个hook_schema()。有没有人知道SimpleTest还有什么需要识别我的表并创建它的副本?

感谢。

2 个答案:

答案 0 :(得分:2)

问题是你必须扩展DrupalWebTestCase并将你的模块添加到setUp

class MyTest extends DrupalWebTestCase {
    function setUp() {
        parent::setUp('mymodule');
    }
}

答案 1 :(得分:0)

看看CCK的SimpleTest实现,看起来你需要:

  function setUp() {
    $args = func_get_args();
    $modules = array_merge(array('my', 'list', 'of', 'modules'), $args);
    call_user_func_array(array('parent','setUp'), $modules);
  }