谁能帮助我在 CakePHP 2.0 的基本保存方法测试用例中需要哪些断言?
我有产品、用户和新闻模型,我正在为模型中的submit
方法编写一个测试用例,News
并且有很多方法/东西要包括我只是想知道什么是真正需要的,什么不是。我有所有型号的基本夹具设置。
我正在测试的方法实际上是这样的:
class News extends AppModel {
public submit($productId, $userId, $newsData) {
// Logic which checks for user and products existence, saves and returns submitted row
}
}
测试用例
public function testSubmit() {
// Save News
$newsData = array(
'News' => array(
'title' => 'Here is the title of the news',
'body' => 'Here is the news body',
'source' => 'News came from here'
)
);
$news = $this->News->submit('product-1', 'user-1', $newsData);
// Now what?
}