Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does PHPUnit Strict mode do?

I am wondering about what "strict mode is in PHPUnit" ?

eg:

phpunit --strict 

or in phpunit.xml

<phpunit strict="true"/> 

I turned it on just to try it and my tests started failing with

PHP_Invoker_TimeoutException: Execution aborted after 1 second 
like image 599
Mike Graf Avatar asked May 09 '12 16:05

Mike Graf


Video Answer


1 Answers

Please note that PHPUnit swallows all output that is emitted during the execution of a test. In strict mode, a test that emits output will fail.

That's all I could find in documentation, but I'd also checked the sources and I found that in strict mode:

  1. Tests with no assertions might be marked as incomplete/failures.
  2. Each test might be run with execution time limit depending on it's size and the presence of the pcntl extension and PHP_Invoker library. There are three timeouts values:

    • timeoutForSmallTests (default value: 1)
    • timeoutForMediumTests (default value: 10)
    • timeoutForLargeTests (default value: 60)

    The test size (small, medium or large) is determined by the PHPUnit_Util_Test::getSize() method:

    • Test cases descending from PHPUnit_Extensions_Database_TestCase or PHPUnit_Extensions_SeleniumTestCase are large.
    • Test cases and individual tests can also be made large or medium by adding them to the 'large' or 'medum' groups, respectively.
    • Otherwise, the test is small.

It's seems that strict mode does only the above three changes, but I'm not absolutely sure about that. I have never studied PHPUnit's sources before, nor used strict mode.

like image 101
Crozin Avatar answered Sep 30 '22 06:09

Crozin