3

我想使用蛋糕测试功能测试我的应用程序,但我的 AppTranslateBehavior(其自定义行为)中使用的 I18nModel 存在问题。我收到一个错误:

在数据源测试中未找到模型 I18nModel 的表 i18n。

在测试用例中,我将“plugin.languages.i18n”(夹具在插件内)添加到 $fixtures,我的夹具看起来像:

class I18nFixture extends CakeTestFixture {

public $name = 'I18n';
public $table = 'i18n';
public $import = array(
    'table' => 'i18n',
);}

我也试过

class I18nModelFixture extends CakeTestFixture {

public $import = 'I18nModel';
public $table = 'i18n';
public $fields = array(
    'id' => array('type' => 'integer', 'key' => 'primary'),
    'locale' => array('type' => 'string', 'length' => 6, 'null' => false),
    'model' => array('type' => 'string', 'null' => false),
    'foreign_key' => array('type' => 'integer', 'null' => false),
    'field' => array('type' => 'string', 'null' => false),
    'content' => array('type' => 'text')
);
public $records = array();}

和许多其他变体,但没有一个起作用。

我错过了什么?

4

1 回答 1

3

您应该使用 cakephp 提供的核心翻译固定装置:

class MyModelTest extends CakeTestCase {
    public $fixtures = array(...,'core.translates');
    ...
}

编辑:夹具名称是 core.translate s,而不是 core.translate

于 2014-06-23T13:39:33.127 回答