我是单元测试的新手,我正在尝试为CakePHP 2.0中的AppModel.php中的函数创建一些测试。
我的AppModelTest.php看起来像:
<?php
App::uses('AppModel', 'Model');
class AppModelTestCase extends CakeTestCase {
public $fixtures = array();
public function setUp() {
parent::setUp();
$this->AppModel = ClassRegistry::init('AppModel');
}
public function tearDown() {
unset($this->AppModel);
ClassRegistry::flush();
parent::tearDown();
}
public function testMultibyteSlug() {
$result = $this->AppModel->slug('abet!"£$%*$%^&yurgerfui94873');
$this->assertEqual($result, 'abet-yurgerfui94873');
.....
当我尝试运行测试时,我得到:
MissingTableException
Database table app_models for model AppModel was not found.
Test case: AppModelTestCase(testMultibyteSlug)
Stack trace:
C:\xampp\htdocs\wdmmg2\lib\Cake\Model\Model.php : 3258
C:\xampp\htdocs\wdmmg2\lib\Cake\Model\Model.php : 720
C:\xampp\htdocs\wdmmg2\app\Test\Case\Model\AppModelTest.php : 39
C:\xampp\htdocs\wdmmg2\app\Test\Case\Model\AppModelTest.php : 39
AppModelTestCase::testMultibyteSlug
任何人都可以帮助我,因为我不知道从哪里开始或我做错了什么。感谢。