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.

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

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址