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

Error while running drupal-check : "PHPUnit_Framework_AssertionFailedError," #224

Closed
akramzairig opened this issue Apr 28, 2021 · 4 comments

Comments

@akramzairig
Copy link

How is drupal-check installed?

drupal-check is installed globally via Composer

Environment:

  • OS: Windows/macOS/Linux (docker)
  • PHP Version: 7.3
  • Drupal core: 8.9.13

Describe the bug
Error while running the vendor/bin/drupal-check command
Console output
Warning: Cannot declare class \PHPUnit_Framework_AssertionFailedError, because the name is already in use in /var/www/html/core/tests/bootstrap.php on line 192 Warning: Class 'PHPUnit\Framework\Constraint\Count' not found in /var/www/html/core/tests/bootstrap.php on line 193 Warning: Class 'PHPUnit\Framework\Error\Error' not found in /var/www/html/core/tests/bootstrap.php on line 194 Warning: Class 'PHPUnit\Framework\Error\Warning' not found in /var/www/html/core/tests/bootstrap.php on line 195 Warning: Class 'PHPUnit\Framework\ExpectationFailedException' not found in /var/www/html/core/tests/bootstrap.php on line 196 Warning: Class 'PHPUnit\Framework\Exception' not found in /var/www/html/core/tests/bootstrap.php on line 197 Warning: Class 'PHPUnit\Framework\MockObject\Matcher\InvokedRecorder' not found in /var/www/html/core/tests/bootstrap.php on line 198 Warning: Class 'PHPUnit\Framework\SkippedTestError' not found in /var/www/html/core/tests/bootstrap.php on line 199 Warning: Cannot declare class \PHPUnit_Framework_TestCase, because the name is already in use in /var/www/html/core/tests/bootstrap.php on line 200 Warning: Class 'PHPUnit\Util\Test' not found in /var/www/html/core/tests/bootstrap.php on line 201 Warning: Class 'PHPUnit\Util\Xml' not found in /var/www/html/core/tests/bootstrap.php on line 202 Fatal error: Cannot redeclare Drupal\Tests\PhpunitCompatibilityTrait::setExpectedException() in /var/www/html/core/tests/Drupal/Tests/PhpunitCompatibilityTrait.php on line 141

@damienmckenna
Copy link

I hit this error on one project but not another. Both have 8.9.14.. I wonder if there's a dependency conflicting somewhere?

@damienmckenna
Copy link

I worked out the problem: there were some dependencies in the "require-dev" portion of the project's composer.json file which were conflicting, I removed a bunch of them and added "drupal/core-dev" to the project and it worked for me.

@jedihe
Copy link

jedihe commented May 20, 2021

Thanks a lot @damienmckenna! your suggestion worked great for me.

The root composer.json had this require-dev section:

    "require-dev": {
        "behat/mink": "~1.7",
        "behat/mink-goutte-driver": "~1.2",
        "jcalderonzumba/gastonjs": "~1.0.2",
        "jcalderonzumba/mink-phantomjs-driver": "~0.3.1",
        "mikey179/vfsstream": "~1.2",
        "phpunit/phpunit": ">=4.8.28 <5",
        "symfony/css-selector": "~2.8"
    }

Which I manually updated to replace all those constraints with just "drupal/core-dev": "^8 || ^9"; then I used composer to properly resolve the new set of constraints by running:

composer require drupal/core-dev:"^8.9.14 || ^9" --dev --update-with-dependencies

Which resulted in a require-dev section that looks like this:

    "require-dev": {
        "drupal/core-dev": "^8.9.14 || ^9"
    }

After that, I was able to run drupal-check (via drush upgrade_status:analyze my_module) without the error about PHPUnit_Framework_AssertionFailedError.

@mglaman
Copy link
Owner

mglaman commented Feb 5, 2022

phpstan-drupal also had fixes around this. Closing out

@mglaman mglaman closed this as completed Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants