phpunit-documentation-english icon indicating copy to clipboard operation
phpunit-documentation-english copied to clipboard

Example for extension with arguments not working

Open kanitkameh opened this issue 4 years ago • 1 comments

Example 10.5 from the documentation for extending phpunit crashes with the following message:

PHP Fatal error:  Uncaught TypeError: Argument 2 passed to MyExtension::__construct() must be of the type int, null given in /mnt/c/Users/kanit/Documents ...

Example 10.5 TestRunner Extension configuration

<extensions>
    <extension class="Vendor\MyUnconfigurableExtension" />
    <extension class="Vendor\MyConfigurableExtension">
        <arguments>
            <string>Hello world!</string>
            <int>15</int>
        </arguments>
    </extension>
</extensions>

However changing the tag <int> to <integer> fixes the problem

...
            <arguments>
                <string>Hello world!</string>
                <integer>15</integer>
            </arguments>
...

kanitkameh avatar Jan 07 '21 00:01 kanitkameh

I just tried Example 10.4 and it didn't work too because the variables $config_1 and $config_2 aren't really the ones passed in the constructor. They should be changed to $value1 and $value2.

kanitkameh avatar Jan 07 '21 01:01 kanitkameh

This type of extensions is no longer supported.

sebastianbergmann avatar Feb 23 '23 06:02 sebastianbergmann