Closed Valicek1 closed 8 years ago
It's not always 200, but I'll look into it. Thanks for those reports... :)
Made some tests... Maybe, it isn't caused by SAPI, but by combination of my code and how your code works. Tester grabs the exception that was thrown and then extracts code. If no exception is thrown, return is 200. But in my error presenter, there is no error thrown. Nette passes catched exception as parameter (and I do the same in my test case) to the ErrorPresenter - and presenters work is to set correct HTTP Status Code.
Maybe, it would be nice to implement something like this:
// ....
// nearly to the end of TPresenter::check
// no exception was thrown - try to get real httpCode from response
$this->__testbench_httpCode = $container->getService('http.response')->getCode());
return $response;
//....
After some tests, I have figured out that Errors were not caused by testbench, but nette tester itself. And yes, it was under CGI/FCGI only - look at this piece of code. My shame, I'm sorry for this issue.
So there is nothing I can solve or improve? May I close this issue?
Yes, this can be closed. I'll do.
When using
TPresenter
,$this->getReturnCode
is always '200'ErrorPresenter.php:
Error:default
Error:default - 404 not found (Passed exception with code as parameter)
Nette Tester 1.7 used as default one PHP-CGI (cgi-fcgi) SAPI, but dev-master (2.x) uses as default SAPI CLI.
Maybe,
checkAction
could have fourth parameterreturnCode
defaulting 200 to be able to easily test for example the ErrorPresenter and other situations with HTTP codes different from 200.