Make WordPress Core

Opened 7 years ago

Last modified 4 years ago

#39237 new defect (bug)

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

Reported by: pbearne's profile 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
7 years ago

  • Keywords needs-patch added

#3 @swissspidy
7 years ago

  • Description modified (diff)

#4 @swissspidy
7 years 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
7 years 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
7 years ago

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

#7 @desrosj
7 years 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
7 years 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
7 years ago

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

or just remove them are they needed?

Paul

#10 @schlessera
6 years ago

Related: #43067

Last edited 4 years ago by SergeyBiryukov (previous) (diff)

#11 @johnbillion
6 years ago

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

#12 @pbearne
6 years 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
6 years ago

@johnbillion I'm currently running PHPUnit 5.7.26.

Note: See TracTickets for help on using tickets.