diff --git a/ChangeLog-10.5.md b/ChangeLog-10.5.md index 39900d2c9ef..5d4e07da0f0 100644 --- a/ChangeLog-10.5.md +++ b/ChangeLog-10.5.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 10.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [10.5.27] - 2024-MM-DD + +### Fixed + +* [#5892](https://github.com/sebastianbergmann/phpunit/issues/5892): Errors during write of `phpunit.xml` are not handled correctly when `--generate-configuration` is used + ## [10.5.26] - 2024-07-08 ### Added @@ -241,6 +247,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi * [#5563](https://github.com/sebastianbergmann/phpunit/issues/5563): `createMockForIntersectionOfInterfaces()` does not automatically register mock object for expectation verification +[10.5.27]: https://github.com/sebastianbergmann/phpunit/compare/10.5.26...10.5 [10.5.26]: https://github.com/sebastianbergmann/phpunit/compare/10.5.25...10.5.26 [10.5.25]: https://github.com/sebastianbergmann/phpunit/compare/10.5.24...10.5.25 [10.5.24]: https://github.com/sebastianbergmann/phpunit/compare/10.5.23...10.5.24 diff --git a/src/TextUI/Command/Commands/GenerateConfigurationCommand.php b/src/TextUI/Command/Commands/GenerateConfigurationCommand.php index 7f450006d5a..8d9e47a20e9 100644 --- a/src/TextUI/Command/Commands/GenerateConfigurationCommand.php +++ b/src/TextUI/Command/Commands/GenerateConfigurationCommand.php @@ -12,6 +12,7 @@ use function fgets; use function file_put_contents; use function getcwd; +use function sprintf; use function trim; use PHPUnit\Runner\Version; use PHPUnit\TextUI\XmlConfiguration\Generator; @@ -58,7 +59,7 @@ public function execute(): Result $generator = new Generator; - file_put_contents( + $result = @file_put_contents( 'phpunit.xml', $generator->generateDefaultConfiguration( Version::series(), @@ -69,11 +70,26 @@ public function execute(): Result ), ); - /* @noinspection MissingDirectorySeparatorInspection */ - print PHP_EOL . 'Generated phpunit.xml in ' . getcwd() . '.' . PHP_EOL; - print 'Make sure to exclude the ' . $cacheDirectory . ' directory from version control.' . PHP_EOL; + if ($result !== false) { + return Result::from( + sprintf( + PHP_EOL . 'Generated phpunit.xml in %s.' . PHP_EOL . + 'Make sure to exclude the %s directory from version control.' . PHP_EOL, + getcwd(), + $cacheDirectory, + ), + ); + } - return Result::from(); + // @codeCoverageIgnoreStart + return Result::from( + sprintf( + PHP_EOL . 'Could not write phpunit.xml in %s.' . PHP_EOL, + getcwd(), + ), + Result::EXCEPTION, + ); + // @codeCoverageIgnoreEnd } private function read(): string