Skip to content

Commit

Permalink
Closes #6115
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jan 30, 2025
1 parent be5aa22 commit c146604
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
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.44] - 2025-MM-DD

### Fixed

* [#6115](https://github.com/sebastianbergmann/phpunit/issues/6115): Backed enumerations with values not of type `string` cannot be used in customized TestDox output

## [10.5.43] - 2025-01-29

### Changed
Expand Down Expand Up @@ -389,6 +395,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.44]: https://github.com/sebastianbergmann/phpunit/compare/10.5.43...10.5
[10.5.43]: https://github.com/sebastianbergmann/phpunit/compare/10.5.42...10.5.43
[10.5.42]: https://github.com/sebastianbergmann/phpunit/compare/10.5.41...10.5.42
[10.5.41]: https://github.com/sebastianbergmann/phpunit/compare/10.5.40...10.5.41
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/TestDox/NamePrettifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private function objectToString(object $value): string
$enumReflector = new ReflectionEnum($value);

if ($enumReflector->isBacked()) {
return $value->value;
return (string) $value->value;

Check failure on line 293 in src/Logging/TestDox/NamePrettifier.php

View workflow job for this annotation

GitHub Actions / Type Checker

LessSpecificReturnStatement

src/Logging/TestDox/NamePrettifier.php:293:24: LessSpecificReturnStatement: The type 'string' is more general than the declared return type 'non-empty-string' for PHPUnit\Logging\TestDox\NamePrettifier::objectToString (see https://psalm.dev/129)
}

return $value->name;
Expand Down
25 changes: 25 additions & 0 deletions tests/end-to-end/regression/6115.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/6115
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--testdox';
$_SERVER['argv'][] = __DIR__ . '/6115/Issue6115Test.php';

require_once __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s

. 1 / 1 (100%)

Time: %s, Memory: %s

Issue6115 (PHPUnit\TestFixture\Issue6115\Issue6115)
1

OK (1 test, 1 assertion)
38 changes: 38 additions & 0 deletions tests/end-to-end/regression/6115/Issue6115Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\Issue6115;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;

enum Enumeration: int
{
case A = 1;
}

final class Issue6115Test extends TestCase
{
public static function provider(): array
{
return [
[
Enumeration::A,
],
];
}

#[DataProvider('provider')]
#[TestDox('$enumeration')]
public function testOne(Enumeration $enumeration): void
{
$this->assertTrue(true);
}
}

0 comments on commit c146604

Please sign in to comment.