johnkary/phpunit-speedtrap

Argument example doesn't work

mihaeu opened this issue · 2 comments

Hey John, thanks for this awesome listener!

I've just stumbled upon a problem that I think I didn't have before (newer PHPUnit version maybe).

Using the following example from your README:

<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
    <arguments>
        <array>
            <element key="slowThreshold"> <!-- Slowness threshold in ms -->
                <integer>500</integer>
            </element>
            <element key="reportLength"> <!-- Number of slow tests to report on -->
                <integer>5</integer>
            </element>
        </array>
    </arguments>
</listener>

I get the following problem

PHP Catchable fatal error:  Argument 1 passed to PHPUnit_Util_XML::xmlToVariable() must be an instance of DOMElement, instance of DOMComment given, called in /opt/lampp/htdocs/movie-manager/vendor/phpunit/phpunit/src/Util/XML.php on line 251 and defined in /opt/lampp/htdocs/movie-manager/vendor/phpunit/phpunit/src/Util/XML.php on line 242

The solution is to simply remove the comments from the example:

<arguments>
    <array>
        <element key="slowThreshold">
            <integer>500</integer>
        </element>
        <element key="reportLength">
            <integer>5</integer>
        </element>
    </array>
</arguments>

So either ignore the comments in your Listener or just remove the comments from the README to avoid this problem when copy & pasting.

I've wasted almost one hour with this problem, I support mihaeu solution of removing the comments from the example

Closed after merging #8.