开发者

CakePHP doesn't create tests tables

I've tried to do some tests, but cakephp doesn't create de test_{tablename} tables! He is trying to use de original tables. Database config:

var $test = array(

        'driver' => 'mysql',
        'persistent' => false,
        'host' => '127.0.0.1',
        'login' => 'root',
        'password' =>开发者_StackOverflow '',
        'database' => 'tests_clubpets',
        'encoding' => 'utf8'
);

Fixture:

class AdminFixture extends CakeTestFixture {
    var $name = 'Admin';

    var $fields = array(
        'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
        ...
        'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
    );

    var $records = array(
        array(
            'id' => 1,
            'nome' => 'Lorem ipsum dolor sit amet',
            ...
    );
}

Model:

class AdminTestCase extends CakeTestCase {
    var $fixtures = array('app.admin');

    function startTest() {
        $this->Admin =& ClassRegistry::init('Admin');
    }

    function endTest() {
        unset($this->Admin);
        ClassRegistry::flush();
    }

}

What can be wrong?


when you create the $test database connection, cake should be trying to make the tables in that database. according to your code that should be in tests_clubpets. make sure the database is created and that the user has permissions on the table. also check you did not make any typeo's


if you want to have your tables named test_{tablename}, use:

'prefix' => 'test_',
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜