4

Does anyone know of the correct way to develop unit tests for a CakePHP 2.3.1 application that utilises MySQL stored procedures?

I've looked on the cake site but the documentation on testing isn't huge. I've checked out SO and Google as well - can't seem to find mention of the problem/situation.

The unit testing is using fixtures, not a real database for the data.

Any help/pointers are really appreciated!

J

4

1 回答 1

3

重载 Fixture 的 create() 方法。不要忘记调用父级的 create() 并删除创建过程语句中结束 END 之后的最终分隔符。

例如:

public function create($db){
    parent::create($db);
    // create stored procedures ...
    $db->execute("CREATE PROCEDURE … <insert SQL here> … END", array('log' => false));
}

create() 方法可以在夹具表创建后执行您需要的任何语句。

我希望它会工作

于 2013-03-26T10:28:23.380 回答