PHPUnit:“传递给 setPost() 的值无效”当传递使用 toArray() 转换的 Zend_Db_Table_Row_Abstract 时
以下代码失败,抛出 Zend_Controller_Exception (“传递给 setPost() 的值无效;必须是值数组或键/值对”)
/** Model_Audit_Luminaire */
$luminaireModel = new Model_Audit_Luminaire();
if (!$fixture = $luminaireModel->getScheduleItem($scheduleId)) {
$this->fail('Could not retrieve fixture from database');
}
$fixtureArray = $fixture->toArray();
$this->getRequest()
->setMethod('POST')
->setPost($fixtureArray);
我执行了 var_dump() 以确保 $fixtureArray 是正确的类型和格式正确...没有明显的问题。
The following code fails throws a Zend_Controller_Exception ("Invalid value passed to setPost(); must be either array of values or key/value pair")
/** Model_Audit_Luminaire */
$luminaireModel = new Model_Audit_Luminaire();
if (!$fixture = $luminaireModel->getScheduleItem($scheduleId)) {
$this->fail('Could not retrieve fixture from database');
}
$fixtureArray = $fixture->toArray();
$this->getRequest()
->setMethod('POST')
->setPost($fixtureArray);
I did a var_dump() to ensure $fixtureArray was the correct type, and formatted properly...no visible problems.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
计划项目行中的任何列是否可以为空?
setPost()
方法为您在数组中传递的每个键/值对调用自身。但如果任何值为 null,则会引发异常。您可能必须循环遍历数组和
setPost()
仅非空值:或者确保您在
getScheduleItem()
中从数据库获取的行方法不包含空值。Are any of the columns in your schedule item row nullable?
The
setPost()
method calls itself for each key/value pair you pass in an array. But if any value is null, it throws an exception.You may have to loop over the array and
setPost()
only values that are non-null:Or else ensure that the row you fetch from the database in your
getScheduleItem()
method contains no nulls.