Skip to content

Test does not complete when using ob_start and fpassthru  #5546

@nyamsprod

Description

@nyamsprod
Q A
PHPUnit version 10.4.x
PHP version PHP8.3.0RC4 (alpine and github actions)
Installation Method Composer

Summary

The test works:

  • with all versions of PHP8.1 until the recent PHP8.3.0RC4 in PHPUnit.
  • Outside of PHPUnit the code works as expected.
  • Test also work with PHPUnit 10.3.1 (I checked the results of the github action)

Current behaviour

The test never ends nor report any failure.

How to reproduce

public function testOutputDoesNotStripBOM(): void
{
      $raw_csv = "\xEF\xBB\xBFjohn,doe,john.doe@example.com\njane,doe,jane.doe@example.com\n";
      $stream = fopen('php://temp', 'r+');
      fwrite($stream, $raw_csv);
      ob_start();
      rewind($stream);
      echo "\xFE\xFF";
      fpassthru($stream);
      $result = ob_get_clean();
      fclose($stream);

      self::assertStringContainsString("\xFE\xFF", $result);
      self::assertStringContainsString("\xEF\xBB\xBF", $result);
      self::assertTrue(str_starts_with($result, "\xFE\xFF\xEF\xBB\xBF"));
}

Expected behavior

Works in PHP8.1+ with PHPUnit 10.4.0 the test ends and pass successfully

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething is brokenversion/10Something affects PHPUnit 10

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions