Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestSuite names conflict with names of built-in classes #2726

Closed
jbaron-gingco opened this issue Jul 4, 2017 · 3 comments
Closed

TestSuite names conflict with names of built-in classes #2726

jbaron-gingco opened this issue Jul 4, 2017 · 3 comments
Assignees
Labels
type/backward-compatibility Something will be/is intentionally broken type/bug Something is broken
Milestone

Comments

@jbaron-gingco
Copy link

Q A
PHPUnit version 6.2.3
PHP version 7.1.5
OS XUbuntu 17.04 (PHP is not the packaged version, but self-compiled)
Installation Method Composer

If a testsuite name in phpunit.xml is the name of a built-in class, an exception is thrown.

Minimal example:

composer.json

{
  "require": {
    "php": "^7.0",
    "roave/security-advisories": "dev-master"
  },
  "require-dev": {
    "php": "^7.0",
    "phpunit/phpunit": "^6.2.2"
  }
}

phpunit.xml

<?xml version="1.0" ?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd">
    <testsuites>
        <testsuite name="DateTime"/>
    </testsuites>
</phpunit>

Same issue occurs with test suite names like "Generator", "Closure" etc., but not with something like "get_class", "strlen" etc.

Expected Result

No tests executed!

Actual Result

(The backtrace was added in line 153 of TestSuite.php by myself)

#0 PHPUnit\Framework\TestSuite->__construct() called at [/home/jost/projects/gingco_appserver/branches/dev_restructuring/InstallerBuilder/tmp/test/vendor/phpunit/phpunit/src/Util/Configuration.php:916]
#1 PHPUnit\Util\Configuration->getTestSuite() called at [/home/jost/projects/gingco_appserver/branches/dev_restructuring/InstallerBuilder/tmp/test/vendor/phpunit/phpunit/src/Util/Configuration.php:875]
#2 PHPUnit\Util\Configuration->getTestSuiteConfiguration() called at [/home/jost/projects/gingco_appserver/branches/dev_restructuring/InstallerBuilder/tmp/test/vendor/phpunit/phpunit/src/TextUI/Command.php:784]
#3 PHPUnit\TextUI\Command->handleArguments() called at [/home/jost/projects/gingco_appserver/branches/dev_restructuring/InstallerBuilder/tmp/test/vendor/phpunit/phpunit/src/TextUI/Command.php:152]
#4 PHPUnit\TextUI\Command->run() called at [/home/jost/projects/gingco_appserver/branches/dev_restructuring/InstallerBuilder/tmp/test/vendor/phpunit/phpunit/src/TextUI/Command.php:141]
#5 PHPUnit\TextUI\Command::main() called at [/home/jost/projects/gingco_appserver/branches/dev_restructuring/InstallerBuilder/tmp/test/vendor/phpunit/phpunit/phpunit:53]

Fatal error: Uncaught PHPUnit\Framework\Exception: Class "DateTime" does not extend PHPUnit\Framework\TestCase.

thrown in /home/jost/projects/gingco_appserver/branches/dev_restructuring/InstallerBuilder/tmp/test/vendor/phpunit/phpunit/src/Framework/TestSuite.php on line 154

@sebastianbergmann
Copy link
Owner

This is a relic of how test suites used to work, back when you had to write classes that extend TestSuite manually to organize your tests. This can probably not be "fixed" before PHPUnit 7.

@sebastianbergmann sebastianbergmann self-assigned this Jul 4, 2017
@sebastianbergmann sebastianbergmann added the type/bug Something is broken label Jul 4, 2017
@sebastianbergmann sebastianbergmann added this to the PHPUnit 7.0 milestone Jul 4, 2017
@sebastianbergmann sebastianbergmann added the type/backward-compatibility Something will be/is intentionally broken label Oct 14, 2017
@sebastianbergmann
Copy link
Owner

I can no longer reproduce this.

$ cat composer.json 
{
    "prefer-stable": true,
    "minimum-stability": "dev",
    "require-dev": {
        "phpunit/phpunit": "^8"
    }
}
$ cat phpunit.xml  
<?xml version="1.0" ?>
<phpunit>
    <testsuites>
        <testsuite name="DateTime"/>
    </testsuites>
</phpunit>
$ ./vendor/bin/phpunit
PHPUnit 8.0-gdda7fcbb5 by Sebastian Bergmann and contributors.

Time: 26 ms, Memory: 4.00MB

No tests executed!

@epdenouden
Copy link
Contributor

Yes, #3454 included a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/backward-compatibility Something will be/is intentionally broken type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants