jurruh
jurruh

Reputation: 119

PhpUnit test passes with Missing argument 1

When I run a test the following warning is given: Missing argument 1 for ...

The unittest passes, is it possible to let the test fail?

This is my PhpUnit.xml

<phpunit bootstrap="bootstrap.php"
         colors="false"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         strict="true">
    <selenium>
        <browser name="Internet Explorer" browser="*iexplore" />
        <browser name="Firefox" browser="*firefox" />
    </selenium>
    <filter>
        <whitelist>
            <directory>../src</directory>
        </whitelist>
    </filter>
    <testsuites>
        <testsuite name="unitTests">
            <directory suffix="Test.php">*</directory>
        </testsuite>
    </testsuites>
    <logging>
        <log type="coverage-html" target="../build/coverage" />
        <log type="coverage-clover" target="../build/logs/clover.xml" />
        <log type="coverage-crap4j" target="../build/logs/crap4j.xml" />
    </logging>
</phpunit>

This is the php log: Missing argument 1 for xx function(), called in xx on line 37 and defined (error type: Warning in xx on line 78)

Upvotes: 1

Views: 512

Answers (1)

jurruh
jurruh

Reputation: 119

I have found a bit hackish solution :)

class THE_GREATEST_EVER_PHPUnit_Framework_TestCase extends \PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass() {
        set_error_handler(function($errno, $errstr, $errfile, $errline) {
            throw new \RuntimeException($errstr . " on line " . $errline . " in file " . $errfile);
        });
    }

    public function tearDown() {
        restore_error_handler();
    }

}

Upvotes: 1

Related Questions