duangaixing1509 2012-09-14 18:15
浏览 56
已采纳

Symfony2 PHPUnit,稍长测试,与Monolog有关的致命错误

I have narrowed my problem down to a single unit-test which involves a pretty clean dbal query. The query involves a nestedsets and the failure occurs when I go from 3 to 4 levels of hierarchical categories. Very little changes in terms of execution time.. And the functionality I'm work with has no problem at 10 level. However, in PhpUnit when I run the test with 4 or more levels -- I get a fatal error.

*To summarize, a query that may take a split second more than usual OR a tab bit more resources is getting me a php fatal error in PHPUnit *

And the Error Looks like this:

Fatal error: Call to undefined method Monolog\Formatter\LineFormatter::stopEvent() in /var/www/my-app/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/Stopwatch.php on line 92

Someone here had a phpUnit fatal error problem on line 92 as well. Could it be related??

I've listed some quirky ways (below) to bypass my problem but I'd still like to know why such a basic test seems to be causing this problem.

  • Run PhpUnit with processIsolation set to "true".
  • Don't access the static::createClient(); in the setUpBeforeClass() method

I've had a respected member of #symfony (Stof) suggest that it looks like I'm improperly DI'ing @logger into a service.. but I've confirmed this doesn't seem to be the by taking the logger service out of any of my services.

Maybe this issue has something to do with a timeout? (The error mentions stopevent and stopwatch). Or maybe this error has something to do with accessing $client = static::createClient(); in setUpBeforeClass().. and then accessing is again in preceding tests.. Regardless.. it's confusing me and as far as I can tell, everything else in my Symfony2 (2.1.1) installation is working perfectly fine.

* LINE 92 of Stopwatch.php .. github source file here *

 /**
 * Stops an event.
 * @param string $name The event name
 * @return StopwatchEvent A StopwatchEvent instance
 */
public function stop($name)
{ return end($this->activeSections)->stopEvent($name);}
  • 写回答

1条回答 默认 最新

  • dqkx69935 2012-09-14 19:45
    关注

    OK. So you grab the last item from the $this->activeSections array and they try to run the stopEvent() method on it. It would seem in this case that the LineFormatter class does not have that method available to it.

    I am not familiar with Monolog, but in a brief glance at their latest GitHUb repo, I can see that neither the LineFormatter or NormalizerFormatter class which it inherits from have such a method.

    It seems like Monolog is not playing nice with Symfony. And that without modifying Monolog and/or the Symfony Stopwatch class, you will not be able to use Stopwatch to profile your Monolog-related code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况