Skip to content

Superfluous whitespace in TestDox output when test method name has a number after the test prefix #6266

Closed
@alexislefebvre

Description

@alexislefebvre
Q A
PHPUnit version 11.5.26 and 12.2.6
PHP version 8.3.6
Installation Method Composer
Show composer info | sort
composer info | sort
myclabs/deep-copy            1.13.3 Create deep copies (clones) of your objects
nikic/php-parser             5.5.0  A PHP parser written in PHP
phar-io/manifest             2.0.4  Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version              3.2.1  Library for handling version information and constraints
phpunit/php-code-coverage    12.3.1 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator    6.0.0  FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker          6.0.0  Invoke callables with a timeout
phpunit/php-text-template    5.0.0  Simple template engine.
phpunit/php-timer            8.0.0  Utility class for timing
phpunit/phpunit              12.2.6 The PHP Unit Testing framework.
sebastian/cli-parser         4.0.0  Library for parsing CLI options
sebastian/comparator         7.1.0  Provides the functionality to compare PHP values for equality
sebastian/complexity         5.0.0  Library for calculating the complexity of PHP code units
sebastian/diff               7.0.0  Diff implementation
sebastian/environment        8.0.2  Provides functionality to handle HHVM/PHP environments
sebastian/exporter           7.0.0  Provides the functionality to export PHP variables for visualization
sebastian/global-state       8.0.0  Snapshotting of global state
sebastian/lines-of-code      4.0.0  Library for counting the lines of code in PHP source code
sebastian/object-enumerator  7.0.0  Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector   5.0.0  Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context  7.0.0  Provides functionality to recursively process PHP variables
sebastian/type               6.0.2  Collection of value objects that represent the types of the PHP type system
sebastian/version            6.0.0  Library that helps with managing the version number of Git-hosted PHP projects
staabm/side-effects-detector 1.0.5  A static analysis tool to detect side effects in PHP code
theseer/tokenizer            1.2.3  A small library for converting tokenized PHP source code into XML and potentially other formats

Summary

The output of --testdox has an issue with spacing.

Current behavior

vendor/bin/phpunit --testdox test.php
PHPUnit 12.2.6 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.6

..                                                                  2 / 2 (100%)

Time: 00:00, Memory: 14.00 MB

Acme
 ✔ One hundred users
 ✔  100 users

OK (2 tests, 2 assertions)

(there is a space before 100 users)

How to reproduce

Create a file test.php with this content:

<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

class AcmeTest extends TestCase
{
    public function testOneHundredUsers(): void
    {
        self::assertSame(1, 1);
    }
    public function test100Users(): void
    {
        self::assertSame(1, 1);
    }
}

Install PHPUnit:

composer require --dev --with-all-dependencies phpunit/phpunit:~11
# or 
composer require --dev --with-all-dependencies phpunit/phpunit:~12

Run the test:

vendor/bin/phpunit --testdox test.php

Expected behavior

It should be shown like this:

Acme
 ✔ One hundred users
 ✔ 100 users

Context

Metadata

Metadata

Labels

feature/testdoxThe TextDox printer/formattertype/bugSomething is brokenversion/11Something affects PHPUnit 11version/12Something affects PHPUnit 12

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions