2
votes

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
Can you show line 92 of Stopwatch.php and several of the lines prior to that?Mike Brant
I added line 92 in the main section with a link to the source of Stopwatch.php on github.. It looks like it's trying to behave like a stopwatch... The fatal error is the big stumper. Seems like along the way something isn't being loaded and therefore error-ing.. But why would would modifying a pretty simple query effect whats being loaded?JustinP

1 Answers

1
votes

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.