【发布时间】:2011-10-12 12:38:14
【问题描述】:
谁能帮助我在 CakePHP 2.0 的基本保存方法测试用例中需要哪些断言?
我有 Product、User 和 News 模型,我希望在 News 模型中为 submit 方法编写一个测试用例,并且有很多方法/东西要包括我只是想知道实际需要什么什么不是。我为所有型号设置了基本的固定装置。
我正在测试的方法实际上是这样的:
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?
}
【问题讨论】:
标签: unit-testing cakephp assertions cakephp-2.0