我创建了一个测试类,其中包含一个测试特定操作的函数:
public function testdoAddItem()
{
$this->assertEquals(0, $this->getConnection()->getRowCount('article'), "Pre-Condition");
#$tableNames = array('article');
#$dataSet = $this->getConnection()->createDataSet($tableNames);
$article = new article();
$article->constructChanger(1, 1, 'Article');
$article->doAddItem();
$this->assertEquals(2, $this->getConnection()->getRowCount('article'), "Inserting failed");
}
我得到第一个断言结果为真,它应该是,但我没有看到应该返回失败断言的第二个返回。我所看到的只是一个空白输出。
这是我的 doAddItem():
$pageid = $this->pageid;
$schoolid = crud::quote($_POST['schoolid']);
$newvalue = crud::quote(strip_tags($_POST['addareatext']));
$title = crud::quote($_POST['title']);
// Inserting the new article
$sql = "INSERT INTO `article`(`id`, `pageid`, `school_id`, `title`, `content`)
VALUES ('', '" . $pageid . "', {$schoolid}, {$title}, {$newvalue});";
$result = crud::rawSelect($sql);