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

Errors during write of phpunit.xml are not handled correctly when --generate-configuration is used #5892

Closed
JustasBalciunas opened this issue Jul 8, 2024 · 0 comments
Assignees
Labels

Comments

@JustasBalciunas
Copy link

Q A
PHPUnit version 11.2.6
PHP version 8.3.8
Installation Method Composer

Summary

After executed --generate-configuration shows Warning about Permission denied but shows message that Generated phpunit.xml in /var/www/html although file was not generated in /var/www/html.

Current behavior

docker@numbers:/var/www/html$ ./vendor/bin/phpunit --generate-configuration
PHPUnit 11.2.6 by Sebastian Bergmann and contributors.

Generating phpunit.xml in /var/www/html

Bootstrap script (relative to path shown above; default: vendor/autoload.php): vendor/testings.php
Tests directory (relative to path shown above; default: tests): testings
Source directory (relative to path shown above; default: src): .
Cache directory (relative to path shown above; default: .phpunit.cache):

Warning: file_put_contents(phpunit.xml): Failed to open stream: Permission denied in /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command/Commands/GenerateConfigurationCommand.php on line 61

Generated phpunit.xml in /var/www/html.
Make sure to exclude the .phpunit.cache directory from version control.

docker@numbers:/var/www/html$ ls -l phpunit.xml
ls: cannot access 'phpunit.xml': No such file or directory

docker@numbers:/var/www/html$ ls -ld
drwxrwxr-x 12 root root 4096 Jul 8 08:22 .

How to reproduce

phpunit/phpunit/src/TextUI/Command/Commands/GenerateConfigurationCommand.php:61

<..>
		if(!file_put_contents(
			'phpunit.xml',
			$generator->generateDefaultConfiguration(
				Version::series(),
				$bootstrapScript,
				$testsDirectory,
				$src,
				$cacheDirectory,
			)
		)) {
			print PHP_EOL . "Unable to generate phpunit.xml in " . getcwd() . '.' . PHP_EOL;
			
			return Result::from();
		}
<...>

Expected behavior

Unable to generate phpunit.xml in /var/www/html.

@JustasBalciunas JustasBalciunas added the type/bug Something is broken label Jul 8, 2024
@sebastianbergmann sebastianbergmann self-assigned this Jul 9, 2024
@sebastianbergmann sebastianbergmann changed the title "--generate-configuration" shows "Generated <...>" after "Warning: <..>: Permission denied <..>" Errors during write of phpunit.xml are not handled correctly when --generate-configuration is used Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants