Problem/Motivation

When updating the acquia_contenthub module, we found that running our test suite against 5.6.32 and below caused php fatal errors. Test output below.

The crux of the issue is use statements for traits contain the same name as the traits in WebTestBase namespace. Not sure why this doesn't fail in php7, but so far its only in php 5.6

$ php core/scripts/run-tests.sh --php /home/travis/.phpenv/shims/php --verbose --url http://localhost:8080 acquia_contenthub
Drupal test run
---------------
Tests to be run:
  - Drupal\acquia_contenthub\Tests\FieldClearingNodeTest
  - Drupal\acquia_contenthub\Tests\IntegrationTest
  - Drupal\acquia_contenthub\Tests\NodeFormTest
  - Drupal\acquia_contenthub\Tests\ParagraphsTest
  - Drupal\acquia_contenthub\Tests\TaxonomyTermTest
  - Drupal\Tests\acquia_contenthub\Unit\ContentHubEntitiesTrackingTest
  - Drupal\Tests\acquia_contenthub\Unit\ContentHubEntityDependencyTest
  - Drupal\Tests\acquia_contenthub\Unit\ContentHubEntityEmbedHandlerTest
  - Drupal\Tests\acquia_contenthub\Unit\Controller\ContentHubExportQueueControllerTest
  - Drupal\Tests\acquia_contenthub\Unit\Controller\ContentHubReindexTest
  - Drupal\Tests\acquia_contenthub\Unit\Encoder\ContentHubCdfEncoderTest
  - Drupal\Tests\acquia_contenthub\Unit\EntityManagerTest
  - Drupal\Tests\acquia_contenthub\Unit\Form\NodeFormTest
  - Drupal\Tests\acquia_contenthub\Unit\Form\NodeTypePreviewImageFormTest
  - Drupal\Tests\acquia_contenthub\Unit\ImportEntityManagerTest
  - Drupal\Tests\acquia_contenthub\Unit\Normalizer\ContentEntityNormalizerTest
  - Drupal\Tests\acquia_contenthub\Unit\Normalizer\ContentEntityViewModesExtractorTest
  - Drupal\Tests\acquia_contenthub\Unit\Plugin\QueueWorker\ContentHubImportQueueBaseTest
  - Drupal\Tests\acquia_contenthub\Unit\QueueItem\ImportQueueItemTest
  - Drupal\Tests\acquia_contenthub\Unit\Session\ContentHubUserSessionTest
Test run started:
  Friday, March 2, 2018 - 06:09
Test summary
------------
Drupal\acquia_contenthub\Tests\FieldClearingNodeTest          45 passes             1 exceptions   9 messages
PHP Fatal error:  Cannot use Drupal\Tests\node\Traits\ContentTypeCreationTrait as ContentTypeCreationTrait because the name is already in use in /home/travis/build/drupal/docroot/core/modules/simpletest/src/WebTestBase.php on line 22
Fatal error: Cannot use Drupal\Tests\node\Traits\ContentTypeCreationTrait as ContentTypeCreationTrait because the name is already in use in /home/travis/build/drupal/docroot/core/modules/simpletest/src/WebTestBase.php on line 22

Proposed resolution

Rename the remaining traits so they don't conflict.

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

japerry created an issue. See original summary.

japerry’s picture

Issue summary: View changes
japerry’s picture

This patch fixes the problem, it looks like BaseBlockCreationTrait already has this fix, so I applied it to the other traits that conflict.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Good catch!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed a843845587 to 8.6.x and 30fa28410a to 8.5.x. Thanks!

tacituseu’s picture

@alexpott: commit message got lost (only "-m").

  • alexpott committed bf9db4f on 8.6.x
    Issue #2949449 by japerry: Traits on WebTestBase cause PHP Fatal error...
alexpott’s picture

Committed and pushed bf9db4f0f3 to 8.6.x and 3ffdb9b2b5 to 8.5.x. Thanks!

  • alexpott committed 3ffdb9b on 8.5.x
    Issue #2949449 by japerry: Traits on WebTestBase cause PHP Fatal error...

Status: Fixed » Closed (fixed)

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