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

Triggered E_USER_ERROR is displayed as . (dot) #5566

Closed
mvorisek opened this issue Nov 19, 2023 · 5 comments
Closed

Triggered E_USER_ERROR is displayed as . (dot) #5566

mvorisek opened this issue Nov 19, 2023 · 5 comments
Labels
feature/test-runner CLI test runner type/bug Something is broken version/10 Something affects PHPUnit 10

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Nov 19, 2023

Q A
PHPUnit version 10.4.2
PHP version 8.2.12
Installation Method Composer

Summary

the following test code:

<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

class Test extends TestCase
{
    public function testUserWarning(): void
    {
        trigger_error('x', \E_USER_WARNING);
        self::assertTrue(true);
    }

    public function testUserError(): void
    {
        trigger_error('x', \E_USER_ERROR);
        self::assertTrue(true);
    }

    public function testRisky(): void
    {
    }
}

Current behavior

is outputing:

PHPUnit 10.4.2 by Sebastian Bergmann and contributors.
Runtime:       PHP 8.2.12
Configuration: /path.../prefix-phpunit.xml.dist
W.R                                                                 3 / 3 (100%)
Time: 00:00.018, Memory: 6.00 MB
There was 1 risky test:
1) Ns...\Test::testRisky
This test did not perform any assertions
/path.../Test.php:25
--
1 test triggered 1 error:
1) /path.../Test.php:21
x
Triggered by:
* Ns...\Test::testUserError
  /path.../Test.php:19
--
1 test triggered 1 warning:
1) /path.../Test.php:15
x
Triggered by:
* Ns...\Test::testUserWarning
  /path.../Test.php:13
OK, but there were issues!
Tests: 3, Assertions: 2, Errors: 1, Warnings: 1, Risky: 1.

How to reproduce

run phpunit with --fail-on-warning --fail-on-risky --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped (display all and fail on all)

Expected behavior

same as above with the following diff:

 ...
 Configuration: /path.../prefix-phpunit.xml.dist
-W.R                                                                 3 / 3 (100%)
+WER                                                                 3 / 3 (100%)
 Time: 00:00.018, Memory: 6.00 MB
 ...

(the exit code and the verbose output (thanks to --display-warnings --display-errors) is fine already)

Any warning must not be displayed as . (dot).

@mvorisek mvorisek added type/bug Something is broken version/10 Something affects PHPUnit 10 labels Nov 19, 2023
@sebastianbergmann
Copy link
Owner

It is the intended behaviour to interpret E_USER_ERROR as a test issue instead of a test error.

@mvorisek
Copy link
Contributor Author

Yes. A test with issue should be visually different in the progress bar.

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Nov 20, 2023

A test with issue should be visually different in the progress bar.

In your opinion, yes.

@sebastianbergmann
Copy link
Owner

I misunderstood what you are trying to report, my bad.

@sebastianbergmann sebastianbergmann added the feature/test-runner CLI test runner label Nov 20, 2023
@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Dec 18, 2023

Test.php

<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

final class Test extends TestCase
{
    public function testUserError(): void
    {
        trigger_error('message', E_USER_ERROR);
    }
}

After #5592, the behavior is now as follows:

PHPUnit 10.5.3-27-gf74f4d993e by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.0

E                                                                   1 / 1 (100%)

Time: 00:00.019, Memory: 4.00 MB

There was 1 error:

1) Test::testUserError
E_USER_ERROR was triggered

/home/sb/Test.php:8

ERRORS!
Tests: 1, Assertions: 0, Errors: 2.

This looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/test-runner CLI test runner type/bug Something is broken version/10 Something affects PHPUnit 10
Projects
None yet
Development

No branches or pull requests

2 participants