测试缺少元素的表单会出现错误 is ErrorController.php
我正在对我的登录表单进行一些测试,但我注意到如果我不发送所有预期的参数,我会收到此错误:
致命错误:在第 47 行对 C:\demo\application\controllers\ErrorController.php 中的非对象调用成员函数 hasResource()
例如,此测试代码给出错误:
public function testLoginPage ()
{
$this->request->setMethod('POST')->setPost(
array('username' => 'foobar');
$this->dispatch('/usuario/login');
}
但如果我发送所有元素,则一切正常正如预期:
public function testLoginPage ()
{
$this->request->setMethod('POST')->setPost(
array('username' => 'foobar','password' => 'secret');
$this->dispatch('/usuario/login');
}
这是正常的吗?我不明白为什么我在 ErrorController.php
上收到错误,连接在哪里?
(我想这可能是一些没有加载的东西,但是为什么当所有元素都加载时它还能工作?)
任何理解这一点的帮助将不胜感激。
谢谢
更新:
我只是在 application.ini 中更改了 db 数据库的错误密码,这给了我同样的错误。现在我什至不认为是形式,但也许在启动时进行了一些调用,这取决于 Zend_Auth 身份。但是致命错误:在非对象上调用成员函数 hasResource()
是什么意思?如何加载该对象?
I'm doing some testing to my login form but I notice that If I dont send all the expected parameters, I get this error:
Fatal error: Call to a member function hasResource() on a non-object in C:\demo\application\controllers\ErrorController.php on line 47
for example this test code gives me error:
public function testLoginPage ()
{
$this->request->setMethod('POST')->setPost(
array('username' => 'foobar');
$this->dispatch('/usuario/login');
}
But if I send all the elements everything works as expected:
public function testLoginPage ()
{
$this->request->setMethod('POST')->setPost(
array('username' => 'foobar','password' => 'secret');
$this->dispatch('/usuario/login');
}
Is this normal? I dont understard why I get an error on ErrorController.php
, where is the connection?
(I thought that maybe is something that not loading, but why is it working when all elemnts are?)
Any help understanding this will be appreciated.
Thanks
Update:
I just change to an incorrect password for db database in the application.ini and that gives me the same error. Now I dont even think is the form but maybe some call at the bootstart that is depending to the Zend_Auth identity. But what means that Fatal error: Call to a member function hasResource() on a non-object
? how to load that object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读您收到的错误消息。您正在对
ErrorController.php
中的非对象调用hasResource()
。您的错误控制器已损坏,但这并不是真正的问题。问题是某个地方抛出异常(可能在您的表单、引导程序或任何地方),从而触发错误控制器。修复或禁用错误处理程序以获取异常消息和堆栈跟踪以找出问题。
禁用错误处理程序
Read the error message you get. You're calling
hasResource()
on a non-object inErrorController.php
. Your error controller is broken, but that's not really the issue here.The issue is that there's an exception being thrown somewhere (possibly in your form, bootstrap, or anywhere really) which triggers the error controller. Fix or disable the error handler to get the exception message and stack trace to find out your problem.
To disable the error handler