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

PHPUnit 6.0 does not work with PHP 7.0.0-7.0.12 #2470

Closed
nyoro712 opened this issue Feb 4, 2017 · 10 comments
Closed

PHPUnit 6.0 does not work with PHP 7.0.0-7.0.12 #2470

nyoro712 opened this issue Feb 4, 2017 · 10 comments
Labels
type/bug Something is broken

Comments

@nyoro712
Copy link

nyoro712 commented Feb 4, 2017

PHPUnit does not work since I updated it to 6.0 from 5.7.9.
The error message is as below:
On PHPUnit 6.0.3

PHP Fatal error: Cannot use SebastianBergmann\CodeCoverage\Exception as CodeCoverageException because the name is already in use in phar://D:/xampp/php/phpunit/phpunit/Framework/TestResult.php on line 24

On PHPUnit 6.0.0, 6.0.1, and 6.0.2 (Maybe this message is the same as #2460 )

PHP Fatal error: Cannot use PHPUnit\Framework\Exception as Exception because the name is already in use in phar://D:/xampp/php/phpunit/phpunit/Framework/Constraint/ExceptionMessageRegularExpression.php on line 12

I'm using PHPUnit with XAMPP on Windows 7 SP1 (64bit), and XAMPP is installed in D:\xampp.

I met the error in the following steps:

  1. Access https://phar.phpunit.de/phpunit.phar by a web browser.
  2. A file phpunit-6.0.3.phar is downloaded automatically.
  3. Rename the file to phpunit.
  4. Move the file to D:\xampp\php.
  5. Run > phpunit --version on cmd.exe
  6. Error
@sebastianbergmann sebastianbergmann added 6.0 type/bug Something is broken labels Feb 4, 2017
@sebastianbergmann
Copy link
Owner

I can reproduce this with PHP 7.0.7 on Windows 10:

C:\Users\Sebastian Bergmann\Desktop>php --version
PHP 7.0.7 (cli) (built: May 25 2016 13:08:31) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
C:\Users\Sebastian Bergmann\Desktop>php phpunit-6.0.3.phar

Fatal error: Cannot use SebastianBergmann\CodeCoverage\Exception as CodeCoverageException because the name is already in use in phar://C:/Users/Sebastian Bergmann/Desktop/phpunit-6.0.3.phar/phpunit/Framework/TestResult.php on line 24

@sebastianbergmann
Copy link
Owner

I cannot reproduce this with PHP 7.1.1 on Windows 10:

C:\Users\Sebastian Bergmann\Desktop>php --version
PHP 7.1.1 (cli) (built: Jan 18 2017 18:38:28) ( NTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
C:\Users\Sebastian Bergmann\Desktop>php phpunit-6.0.3.phar
PHPUnit 6.0.3 by Sebastian Bergmann and contributors.

Usage: phpunit [options] UnitTest [UnitTest.php]
       phpunit [options] <directory>

Code Coverage Options:

  --coverage-clover <file>    Generate code coverage report in Clover XML format.
  --coverage-crap4j <file>    Generate code coverage report in Crap4J XML format.
  --coverage-html <dir>       Generate code coverage report in HTML format.
  --coverage-php <file>       Export PHP_CodeCoverage object to file.
  --coverage-text=<file>      Generate code coverage report in text format.
                              Default: Standard output.
  --coverage-xml <dir>        Generate code coverage report in PHPUnit XML format.
  --whitelist <dir>           Whitelist <dir> for code coverage analysis.
  --disable-coverage-ignore   Disable annotations for ignoring code coverage.

Logging Options:

  --log-junit <file>          Log test execution in JUnit XML format to file.
  --log-teamcity <file>       Log test execution in TeamCity format to file.
  --testdox-html <file>       Write agile documentation in HTML format to file.
  --testdox-text <file>       Write agile documentation in Text format to file.
  --testdox-xml <file>        Write agile documentation in XML format to file.
  --reverse-list              Print defects in reverse order

Test Selection Options:

  --filter <pattern>          Filter which tests to run.
  --testsuite <name,...>      Filter which testsuite to run.
  --group ...                 Only runs tests from the specified group(s).
  --exclude-group ...         Exclude tests from the specified group(s).
  --list-groups               List available test groups.
  --list-suites               List available test suites.
  --test-suffix ...           Only search for test in files with specified
                              suffix(es). Default: Test.php,.phpt

Test Execution Options:

  --dont-report-useless-tests Do not report tests that do not test anything.
  --strict-coverage           Be strict about @covers annotation usage.
  --strict-global-state       Be strict about changes to global state
  --disallow-test-output      Be strict about output during tests.
  --disallow-resource-usage   Be strict about resource usage during small tests.
  --enforce-time-limit        Enforce time limit based on test size.
  --disallow-todo-tests       Disallow @todo-annotated tests.

  --process-isolation         Run each test in a separate PHP process.
  --globals-backup            Backup and restore $GLOBALS for each test.
  --static-backup             Backup and restore static attributes for each test.

  --colors=<flag>             Use colors in output ("never", "auto" or "always").
  --columns <n>               Number of columns to use for progress output.
  --columns max               Use maximum number of columns for progress output.
  --stderr                    Write to STDERR instead of STDOUT.
  --stop-on-error             Stop execution upon first error.
  --stop-on-failure           Stop execution upon first error or failure.
  --stop-on-warning           Stop execution upon first warning.
  --stop-on-risky             Stop execution upon first risky test.
  --stop-on-skipped           Stop execution upon first skipped test.
  --stop-on-incomplete        Stop execution upon first incomplete test.
  --fail-on-warning           Treat tests with warnings as failures.
  --fail-on-risky             Treat risky tests as failures.
  -v|--verbose                Output more verbose information.
  --debug                     Display debugging information.

  --loader <loader>           TestSuiteLoader implementation to use.
  --repeat <times>            Runs the test(s) repeatedly.
  --teamcity                  Report test execution progress in TeamCity format.
  --testdox                   Report test execution progress in TestDox format.
  --testdox-group             Only include tests from the specified group(s).
  --testdox-exclude-group     Exclude tests from the specified group(s).
  --printer <printer>         TestListener implementation to use.

Configuration Options:

  --bootstrap <file>          A "bootstrap" PHP file that is run before the tests.
  -c|--configuration <file>   Read configuration from XML file.
  --no-configuration          Ignore default configuration file (phpunit.xml).
  --no-coverage               Ignore code coverage configuration.
  --no-extensions             Do not load PHPUnit extensions.
  --include-path <path(s)>    Prepend PHP's include_path with given path(s).
  -d key[=value]              Sets a php.ini value.
  --generate-configuration    Generate configuration file with suggested settings.

Miscellaneous Options:

  -h|--help                   Prints this usage information.
  --version                   Prints the version and exits.
  --atleast-version <min>     Checks that version is greater than min and exits.

  --check-version             Check whether PHPUnit is the latest version.

Looks like this is related to the PHP version rather than to the operating system.

@GrahamCampbell
Copy link
Contributor

I cannot reproduce this with PHP 7.1.1 on Windows 10:

That's just pure luck on the non-deterministic order that files get required I think?

@sebastianbergmann
Copy link
Owner

The PHAR does not use autoloading.

@sebastianbergmann
Copy link
Owner

I can reproduce this with PHP 7.0.7 on Linux.

@sebastianbergmann
Copy link
Owner

Okay, it looks like this is a similar issue to the one fixed in 1044b8e. It will be fixed shortly.

It's interesting, though, that recent/current versions of PHP 7 do not seem to be affected by this. At least they do not error out on startup.

@GrahamCampbell
Copy link
Contributor

👍

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Feb 4, 2017

As you can see in https://travis-ci.org/sebastianbergmann/phpunit/builds/198346201, the current state of the 6.0 branch does not work for PHP 7.0.0-7.0.12. Starting with PHP 7.0.13 "everything is fine". Looks to me that since version 7.0.13 is hiding the problem. I think this is a bug.

@sebastianbergmann sebastianbergmann changed the title PHPUnit 6.0 does not work by PHP fatal error PHPUnit 6.0 does not work with PHP 7.0.0-7.0.12 Feb 4, 2017
@sebastianbergmann
Copy link
Owner

@nikic just explained:

"As of 7.0.13 collisions are only checked within a single file, always. Previously that depended on symbol type, file order and whether or not you're using opcache. Basically it's fine to shadow a symbol in the namespace using an import, as long as it's not blatantly wrong (shadowing a symbol in the same file)."

@nikic
Copy link

nikic commented Feb 4, 2017

Relevant bug on the PHP side: https://bugs.php.net/bug.php?id=66773

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

No branches or pull requests

4 participants