Problem/Motivation

phpunit fails to run tests because of

Fatal error: Cannot redeclare class Drupal\Tests\migrate\Unit\TestMigration in drupal/core/modules/migrate/tests/src/Unit/MigrationTest.php on line 171

Call Stack:
    0.0002     234288   1. {main}() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/phpunit:0
    0.0091    1106976   2. PHPUnit_TextUI_Command::main() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/phpunit:47
    0.0091    1107600   3. PHPUnit_TextUI_Command->run() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/TextUI/Command.php:100
    0.0091    1110464   4. PHPUnit_TextUI_Command->handleArguments() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/TextUI/Command.php:111
    0.3329    1951872   5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/TextUI/Command.php:649
    0.3329    1953136   6. PHPUnit_Util_Configuration->getTestSuite() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/Util/Configuration.php:870
    3.1698  127304496   7. PHPUnit_Framework_TestSuite->addTestFiles() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/Util/Configuration.php:959
    5.2540  203369248   8. PHPUnit_Framework_TestSuite->addTestFile() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/Framework/TestSuite.php:409
    5.2545  203664512   9. PHPUnit_Util_Fileloader::checkAndLoad() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/Framework/TestSuite.php:335
    5.2545  203664664  10. PHPUnit_Util_Fileloader::load() /Users/mkalkbrenner/git/drupal/vendor/phpunit/phpunit/src/Util/Fileloader.php:38

That happens for example when you run the search_api_solr tests like:
./vendor/bin/phpunit --group search_api_solr_multilingual -c "modules/search_api_solr/phpunit.xml.travis"

The problem is that drupal/core/modules/migrate/tests/src/Unit/MigrationTest.php and drupal/core/modules/migrate/tests/src/Unit/MigrationPluginManagerTest.php both declare the same class \Drupal\Tests\migrate\Unit\TestMigration.

The problem was introduced into 8.2.x and 8.1.x by the commit of #2710133: Follow up to #2561697 - Migration should not choke when the content_node_field table isn't available.

Proposed resolution

Rename class TestMigration to TestMigrationMock in drupal/core/modules/migrate/tests/src/Unit/MigrationPluginManagerTest.php.

Remaining tasks

Test the patch. None.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkalkbrenner created an issue. See original summary.

mkalkbrenner’s picture

mkalkbrenner’s picture

mkalkbrenner’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2725739.patch, failed testing.

mkalkbrenner’s picture

Status: Needs work » Needs review
FileSize
1.42 KB

uploaded wrong patch file :-(

mkalkbrenner’s picture

Issue summary: View changes

With this patch applied, search_api_solr tests pass again.

neclimdul’s picture

Status: Needs review » Reviewed & tested by the community

Fixes the problem for me as well. Looks good.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed af4dc7f and pushed to 8.1.x and 8.2.x. Thanks!

  • alexpott committed e5b5f31 on 8.2.x
    Issue #2725755 by mkalkbrenner: Fatal error: Cannot redeclare class...
neclimdul’s picture

Thank you both!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.