在测试环境中Symfony2错误500而不是404

时间:2014-08-14 14:30:59

标签: php symfony jenkins behat error-code

我对给定的控制器动作进行了Behat测试,这里是代码(Symfony2.5)

public function sendContactFormAction(Request $request, TrainingCenter $trainingCenter)
{
    if (!$trainingCenter->isInstituteProfileVisible()) {
        throw $this->createNotFoundException(sprintf('The center "%s" (%d) is not visble.', $trainingCenter->getName(), $trainingCenter->getId()));
    }

    if (!$trainingCenter->canBeContactedFromProfile()) {
        throw new AccessDeniedHttpException(sprintf('The center "%s" (%d) can\'t be contacted by email.', $trainingCenter->getName(), $trainingCenter->getId()));
    }

它在我们的开发工作站中运行良好,但在我们的集成平台(Jenkins)上,那些throws语句引发了500个异常,而不是404或403,我找不到原因。

1 个答案:

答案 0 :(得分:0)

事实上,这是由于MetaClass deserialise函数中的jmsserializer包生成的通知。清除所有缓存并重新构建测试后,它现在可以正常工作。感谢。