ComposerIntegrationTest and omposerValidateTest fail if run from a composer installed site

Created on 3 September 2024, 3 months ago

Problem/Motivation

If you install Drupal via composer create-project, and run

../vendor/bin/phpunit --group OpenTelemetry (or any other test group), you get these errors:

1) Drupal\Tests\Composer\Generator\BuilderTest::testBuilder
The data provider specified for Drupal\Tests\Composer\Generator\BuilderTest::testBuilder is invalid
Class "Drupal\Composer\Composer" not found

/var/www/html/web/core/tests/Drupal/Tests/Composer/Generator/BuilderTest.php:91

2) Drupal\Tests\ComposerIntegrationTest::testComposerTilde
The data provider specified for Drupal\Tests\ComposerIntegrationTest::testComposerTilde is invalid
The "/var/www/html/web/composer" directory does not exist.

/var/www/html/web/core/tests/Drupal/Tests/ComposerIntegrationTest.php:55

3) Drupal\BuildTests\Composer\ComposerValidateTest::testValidateComposer
The data provider specified for Drupal\BuildTests\Composer\ComposerValidateTest::testValidateComposer is invalid
The "/var/www/html/web/composer" directory does not exist.

/var/www/html/web/core/tests/Drupal/BuildTests/Composer/ComposerValidateTest.php:29

--

There were 2 PHPUnit test runner warnings:

1) No tests found in class "Drupal\Tests\Composer\Generator\BuilderTest".

2) No tests found in class "Drupal\BuildTests\Composer\ComposerValidateTest". 

This is because there's no composer in that location when you use composer create project.

While we don't have to support all tests passing when using composer create-project, it's reasonable to want to run one or two tests or use @group.

I don't think we can make this test find the composer directory, but we could possibly try to skip the test if it can't find the composer directory in the first place. Not sure how that works with phpunit test discovery.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
PHPUnit 

Last updated about 10 hours ago

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024