PHPUnit Maximum Execution Time
When I look at the PHP configuration, it says max_execution_time = 0, however, my PHPUnit script times out after 120 seconds. My php.ini file indicates it should be 700 seconds (for development machines.)
I can't seem to alter this. I've tried adding max_execution_time=0 to the PHPUnit config, but no luck.
Please sign in to leave a comment.
Well, if you are executing "normal" PHPUnit (which is in CLI mode) and not "PHPUnit on Server" one, then max_execution_time = 0 by default.
If you want to check the php.ini value, then execute this simple script in CLI mode and find that setting:
If you use this one, you will see which php.ini file was used exactly:
Also, by using PHP Interpreters management (Settings | PHP), you can override any configuration variable with your custom value (Advanced | Configuration Options).
Even PHPUnit run configuration has "Command Line | Interpreter options" field. Example:
http://www.php.net/manual/en/features.commandline.options.php
If you see only 120 seconds -- maybe it's PHPUnit itself? Maybe it has some default time limit for single test execution? I really doubt -- will just quote their ooold ticket: "Not a PHPUnit issue. Besides, you should be able to use phpunit -d max_execution_time=0 ... to achieve what you want."
But please check your phpunit.xml (or whatever config file you may be using) -- maybe you have <php> ... </php> section, where you can override php.ini settings: http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables
Ok, this is showing me max_execution_time of 120. However, I use set_time_limit(300) just about that call (top of the bootstrap.php file.) My php.ini file is set to 700. I've tried using
Has no effect. It seems like nothing I do changes the time limit from 120.
And no, nothing in the phpunit.xml file.
OK.Few more things to check:
1) If you search your php.ini for max_execution_time -- what do you find? 700?
2) When executing phpinfo() (with no params or with INFO_GENERAL), do you see Additional .ini files parsed => (none) or there are some extra files parsed?
3) Back to php.ini -- if you search for auto_prepend_file -- what do you find?
4) When executing phpinfo(), how does the line with max_execution_time looks exactly? Like this: max_execution_time => 120 => 120 or a bit different?
From my php.ini file:
When executing phpinfo(), it displays Additional .ini files parsed => (none)
Again from my php.ini
Hmm, the phpinfo() actually looks like this:
What does that mean?
The thing is, this works fine with XDebug - meaning, I can pause the script for 10 minutes and it won't timeout. However, with PHPUnit, it's behaving differently.
As far as I'm aware (after checking comment in php.ini for that setting as well after reading some articles on internet), this setting has NO effect for CLI mode, as it is hardcoded to 0.
The format is:
So .. AFAIK it has to be some script that set the time limit (as if that value is passed as a parameter to php.exe, it will look differently -- see below). In any case, you should be able to override that value with set_time_limit() -- at least it does work here.
Let me clarify this moment: as I understand you've added call to phpinfo() into your bootstrap.php file that is executed with PHPUnit tests and you checking these values by executing your tests and checking generated output. Is that correct?
If so -- have you tried execuing that directive as separate file (e.g. info.php) ? Do you see different results?
What about executing it directly from command line -- will the value be different?
For example, when excuting this one:
the result should be:
If you put set_time_limit(1234); before call to phpinfo(), with the above command line the result should be
---
Considering that "this works fine with XDebug" .. I can only suggest checking your code (whole project including all libraries) -- please scan for set_time_limit(). That's what I would do as from overhere I can't think of any other places.
Keith,


Do you still have the issue?
You can override 'max_execution_time' option in PHP interpreter configuration:
Examinate your configuration using 'Show phpinfo' action:
Thank you for feedback!