WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 4 months ago

#39237 new defect (bug)

PHPunit coverage reports fail if the is out to the stdout or header

Reported by: pbearne Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch dev-feedback
Focuses: Cc:

Description (last modified by swissspidy)

trying to get the coverage report to work :-)

https://phpunit.de/manual/current/en/textui.html

and their error due to the ech statements in the phpunit install.php and bootstrap.php

i.e.

<?php
echo "Installing..." . PHP_EOL;

and due to the header value been set in wp_redirect() in pluggable.php why this is running for unittest ???

it looks like we need to test for if a coverage report is been created and not echo to the console

Change History (13)

#2 @pbearne
19 months ago

  • Keywords needs-patch added

#3 @swissspidy
17 months ago

  • Description modified (diff)

#4 @swissspidy
17 months ago

  • Keywords dev-feedback added

I noticed the same a while ago. It used to work, but perhaps something changed in PHPUnit.

@jorbin @netweb Maybe you guys have some ideas?

#5 @pbearne
16 months ago

It could that its the coverage reports.

Happy to provide patch for this but we will lose the current stdout if I do

#6 @swissspidy
15 months ago

  • Milestone changed from Awaiting Review to Future Release
  • Version trunk deleted

#7 @desrosj
15 months ago

  • Summary changed from PHPunint coverage reports fail if the is out to the stdout or header to PHPunit coverage reports fail if the is out to the stdout or header

#8 @pbiron
11 months ago

I think the underlying problem here is also preventing me from writing unit tests for export.

I'm trying to have something like the following in a unit test:

ob_start();

export_wp();

$wxr = ob_get_flush();
// $wxr should now contain the exported XML as a string

When export_wp() calls header(...) an exception is raised because "headers already sent".

Does anyone have a work around that I could use to get the output of an export?

#9 @pbearne
11 months ago

I think we need to add a flag so we don't output to stdout

or just remove them are they needed?

Paul

#11 @johnbillion
4 months ago

@pbearne @swissspidy @pbiron Which version of PHPUnit are you using?

#12 @pbearne
4 months ago

@johnbillion I was doing this in VVV but it has been a while since I checked it was still broken

The current PHPUnit in vvv is 6.5.5

Hope this helps

Paul

#13 @swissspidy
4 months ago

@johnbillion I'm currently running PHPUnit 5.7.26.

Note: See TracTickets for help on using tickets.