Skip to content

Commit

Permalink
Closes #5892
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jul 9, 2024
1 parent dfabc54 commit 2a2c5fe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-10.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 21 additions & 5 deletions src/TextUI/Command/Commands/GenerateConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,7 +59,7 @@ public function execute(): Result

$generator = new Generator;

file_put_contents(
$result = @file_put_contents(
'phpunit.xml',
$generator->generateDefaultConfiguration(
Version::series(),
Expand All @@ -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
Expand Down

0 comments on commit 2a2c5fe

Please sign in to comment.