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

Risky Test Check for Output Buffering is performed before after-test methods are called #5456

Closed
sebastianbergmann opened this issue Aug 3, 2023 · 0 comments
Assignees
Labels
feature/test-runner CLI test runner type/bug Something is broken

Comments

@sebastianbergmann
Copy link
Owner

Test.php

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

final class Test extends TestCase
{
    public function testOne(): void
    {
        $this->assertTrue(true);
        
        ob_start();
    }

    public function tearDown(): void
    {
        ob_end_clean();
    }
}

Actual

Test Runner Output

phpunit Test.php                    
PHPUnit 10.2.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.9

R                                                                   1 / 1 (100%)

Time: 00:00.018, Memory: 4.00 MB

There was 1 risky test:

1) Test::testOne
Test code or tested code did not close its own output buffers

/home/sb/Test.php:6

OK, but there are issues!
Tests: 1, Assertions: 1, Notices: 1, Risky: 1.

Event Log

PHPUnit Started (PHPUnit 10.2.7 using PHP 8.2.9 (cli) on Linux)
Test Runner Configured
Test Suite Loaded (1 test)
Event Facade Sealed
Test Runner Started
Test Suite Sorted
Test Runner Execution Started (1 test)
Test Suite Started (Test, 1 test)
Test Preparation Started (Test::testOne)
Test Prepared (Test::testOne)
Assertion Succeeded (Constraint: is true, Value: true)
Test Considered Risky (Test::testOne)
Test code or tested code did not close its own output buffers
Test Triggered PHP Notice (Test::testOne)
ob_end_clean(): Failed to delete buffer. No buffer to delete
After Test Method Called (Test::tearDown)
After Test Method Finished:
- Test::tearDown
Test Finished (Test::testOne)
Test Suite Finished (Test, 1 test)
Test Runner Execution Finished
Test Runner Finished
PHPUnit Finished (Shell Exit Code: 0)

Expected

Test Runner Output

PHPUnit 10.2.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.9

.                                                                   1 / 1 (100%)

Time: 00:00.011, Memory: 4.00 MB

OK (1 test, 1 assertion)

Event Log

PHPUnit Started (PHPUnit 10.2.7 using PHP 8.2.9 (cli) on Linux)
Test Runner Configured
Test Suite Loaded (1 test)
Event Facade Sealed
Test Runner Started
Test Suite Sorted
Test Runner Execution Started (1 test)
Test Suite Started (Test, 1 test)
Test Preparation Started (Test::testOne)
Test Prepared (Test::testOne)
Assertion Succeeded (Constraint: is true, Value: true)
Test Passed (Test::testOne)
After Test Method Called (Test::tearDown)
After Test Method Finished:
- Test::tearDown
Test Finished (Test::testOne)
Test Suite Finished (Test, 1 test)
Test Runner Execution Finished
Test Runner Finished
PHPUnit Finished (Shell Exit Code: 0)
@sebastianbergmann sebastianbergmann added type/bug Something is broken feature/test-runner CLI test runner labels Aug 3, 2023
@sebastianbergmann sebastianbergmann self-assigned this Aug 3, 2023
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
Projects
None yet
Development

No branches or pull requests

1 participant