在cakephp上拖放并创建带有固定装置的表
我已经看到了这个问题: 但我认为这个链接是旧的 我想创建一个测试,在这个测试中,我正在加载装置,所以测试放置表并用记录创建它 我的问题是:测试会删除taboles,但它不会重新创建它 这是我装载固定装置的模型:在cakephp上拖放并创建带有固定装置的表,php,cakephp,testing,Php,Cakephp,Testing,我已经看到了这个问题: 但我认为这个链接是旧的 我想创建一个测试,在这个测试中,我正在加载装置,所以测试放置表并用记录创建它 我的问题是:测试会删除taboles,但它不会重新创建它 这是我装载固定装置的模型: App::uses('Post', 'Model'); class PostTest extends CakeTestCase { public $fixtures = array('app.post'); public function setUp() {
App::uses('Post', 'Model');
class PostTest extends CakeTestCase {
public $fixtures = array('app.post');
public function setUp() {
parent::setUp();
$this->Post = ClassRegistry::init('Post');
}
public function testSetTemplate() {
$this->assertEquals('1', '1');
}
}
这是我的夹具文件:
class PostFixture extends CakeTestFixture {
public $import = array('model' => 'Post', 'records' => true);
public $name = 'Post';
public $table = 'posts';
public $fields = array(
'id' => array('type' => 'integer', 'length' => 36, 'key' => 'primary'),
'created' => array('type' => 'datetime'),
'modifed' => array('type' => 'datetime')
);
public $records = array(
array(
'id' => '1',
'created' => '2014-01-17 12:31:41',
'modified' => '2014-07-22 09:50:42'
),
);
}
我也尝试过:
public $import = array('model' => 'Post', 'records' => false);
同样的事情测试删除表,但不创建它
我需要在删除记录后创建它
错误在哪里?为什么测试不重新创建它,而只是删除它
谢谢?可能…是我已经读过但没有帮助我的链接之一:(@ndmAnd)它没有帮助,因为您正确地使用了单独的数据库进行测试连接,或者使用了唯一的前缀?我正在使用单独的数据库进行测试