Cakephp 在应用程序测试中包含标签插件中的夹具
我正在我的解决方案模型上使用优秀的CakeDC标记插件:Cakephp 在应用程序测试中包含标签插件中的夹具,cakephp,phpunit,cakedc,Cakephp,Phpunit,Cakedc,我正在我的解决方案模型上使用优秀的CakeDC标记插件: class Solution extends AppModel { public $actsAs = array( 'Tags.Taggable', 'Search.Searchable', ); } 我有一个SolutionsController::搜索方法: App::uses('AppController', 'Controller'); class SolutionsControl
class Solution extends AppModel {
public $actsAs = array(
'Tags.Taggable',
'Search.Searchable',
);
}
我有一个SolutionsController::搜索方法:
App::uses('AppController', 'Controller');
class SolutionsController extends AppController {
public $components = array(
'Paginator',
'Search.Prg',
);
public $presetVars = true; // using the model configuration ('Search' plugin)
public function search() {
$this->Prg->commonProcess();
$this->Paginator->settings['conditions'] = $this->Solution->parseCriteria($this->Prg->parsedParams());
$solutions = $this->Paginator->paginate();
if (!empty($solutions)) {
$this->Session->setFlash('Solutions found');
} else {
$this->Session->setFlash('No solutions found');
}
$this->set('solutions', $solutions);
$this->render('index');
}
我正在尝试为此方法编写一个测试:
App::uses('SolutionsController', 'Controller');
class SolutionsControllerTest extends ControllerTestCase {
public $fixtures = array(
'app.solution',
'plugin.tags.tag'
);
public function testSearchForOneResultShouldOutputText() {
$data = array('search' => 'fiery');
$result = $this->Solution->search($data);
debug($result);
$expected = array(
'id' => 3,
'name' => 'fiery-colored horse',
'shortdesc' => 'war',
'body' => 'it was granted to the one seated on it..',
'category_id' => 3,
'created_by' => 1,
'modified_by' => 1,
'created' => '2014-02-14 21:28:46',
'modified' => '2014-02-14 21:28:46'
);
$this->assertContains($expected);
}
}
我在运行测试时遇到以下错误:
缺少数据库表
错误:在数据源测试中找不到模型标记的表标记
我已经尝试将插件标记fixture复制到我的apptest/fixtures文件夹,并将其作为appfixture包含。我无法运行我的测试。如何让我的测试从中查看标记装置并运行?问题原来是我的SolutionsFixture,它导入了表架构和记录,然后还包括一个$records数组oops。重新烘焙此设备以导入架构或记录都无法解决此错误。您是否在配置中配置了测试数据库?指定的用户是否具有创建表权限?是和是;在我将插件标记行为添加到解决方案模型之前,我的应用程序中模型的测试数据库和夹具创建一直有效。如果从Web界面运行插件测试,插件测试是否会运行?您的代码看起来正常。标记插件测试运行良好:32/32测试方法完成:32次通过,0次失败,80次断言,0次异常。app\Plugin\Tags,注意大小写。应该是标签文件夹。