10000 [PhpUnitBridge] Create a predictable symlink pointing to the local install by dunglas · Pull Request #37974 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PhpUnitBridge] Create a predictable symlink pointing to the local install #37974

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

Merged
merged 0 commits into from
Aug 28, 2020

Conversation

dunglas
Copy link
Member
@dunglas dunglas commented Aug 28, 2020
Q A
Branch? 4.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

Static analysis tools such as PHPStan need to be able to autoload classes provided by to work. It's also useful to use the assertions provided by PHPUnit with other testing tools such as Behat.
When using simple-phpunit, PHPUnit isn't installed in the vendor/ directory, consequently other tools cannot autoload its classes.

A workaround is to configure these tools to load the autoloader installed by simple-phpunit. Example with PHPstan:

parameters:
	bootstrapFiles:
		- vendor/bin/.phpunit/phpunit-9.2-0/vendor/autoload.php

However, the path of the autoloader isn't predictable: it depends of PHPUnit version.

This PR changes simple-phpunit to create a symlink with a predictable path (vendor/.phpunit/phpunit) pointing to the currently used version of PHPUnit, so it is possible to hardcode this value in config files.

The symlink is recreated before every run, so if a different version of PHPUnit must be used because the PHP version in use is different from the previous run (frequent when developing libraries compatible with multiple PHP versions), it still works.

@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Aug 28, 2020
@fabpot
Copy link
Member
fabpot commented Aug 28, 2020

Thank you @dunglas.

@fabpot fabpot merged commit ac96fda into symfony:4.4 Aug 28, 2020
@fabpot fabpot force-pushed the feat/phpunit-simlink branch from 539870d to bf7654f Compare August 28, 2020 10:27
@dunglas dunglas deleted the feat/phpunit-simlink branch October 26, 2020 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0