Problem/Motivation

The option to change the printer configuration is printerClass in phpunit config files but --printer on CLI.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webflo created an issue. See original summary.

webflo’s picture

tstoeckler’s picture

Issue summary: View changes
Status: Active » Reviewed & tested by the community
klausi’s picture

Issue tags: +Quickfix

RTBC +1

webflo’s picture

Fixed line wrapping.

webflo’s picture

Issue tags: +rc eligible

Docs are rc eligible

anavarre’s picture

I'm confused. This was changed in #2760905: The documentation should be more explicit about PHPUnit requesting the webserver user to perform all functional tests (commit)

When I have --printerClass, the output is:

$ sudo -u www-data ./vendor/bin/phpunit -c core -v --debug core/modules/help/tests/src/Functional/HelpTest.php 
[sudo] password for drucker: 
PHPUnit 4.8.11 by Sebastian Bergmann and contributors.

Runtime:	PHP 7.0.11-1~dotdeb+8.1
Configuration:	/var/www/html/drucker/core/phpunit.xml


Starting test 'Drupal\Tests\help\Functional\HelpTest::testHelp'.
.

Time: 1.74 minutes, Memory: 4.00Mb

OK (1 test, 81 assertions)

HTML output was generated
http://drucker.local/sites/simpletest/browser_output/Drupal_Tests_help_Functional_HelpTest-1-91599302.html
http://drucker.local/sites/simpletest/browser_output/Drupal_Tests_help_Functional_HelpTest-2-91599302.html
http://drucker.local/sites/simpletest/browser_output/Drupal_Tests_help_Functional_HelpTest-3-91599302.html
http://drucker.local/sites/simpletest/browser_output/Drupal_Tests_help_Functional_HelpTest-4-91599302.html
(snipped)

When I have --printer, the output is:

$ sudo -u www-data ./vendor/bin/phpunit -c core -v --debug core/modules/help/tests/src/Functional/HelpTest.php 
PHPUnit 4.8.11 by Sebastian Bergmann and contributors.

Runtime:	PHP 7.0.11-1~dotdeb+8.1
Configuration:	/var/www/html/drucker/core/phpunit.xml


Starting test 'Drupal\Tests\help\Functional\HelpTest::testHelp'.
.

Time: 1.52 minutes, Memory: 4.00Mb

OK (1 test, 81 assertions)

FTR the bit of code I'm using in phpunit.xml is (either with --printer or --printerClass, then):

<phpunit bootstrap="tests/bootstrap.php" colors="true"
         beStrictAboutTestsThatDoNotTestAnything="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutChangesToGlobalState="true"
         checkForUnintentionallyCoveredCode="false"
         printer="\Drupal\Tests\Listeners\HtmlOutputPrinter">
tstoeckler’s picture

Status: Reviewed & tested by the community » Needs review
webflo’s picture

Tested all combinations with cores phpunit (PHPUnit 4.8.11) again. printerClass works in phpunit.xml(.dist). --printer works on CLI.

anavarre’s picture

Status: Needs review » Needs work

So I think we should clarify that. Committing the patch as is would mean removing a useful reference to --printerClass which is exactly what people need to find in phpunit.xml.dist. I agree it's good to also explain why --printer needs to be used for the CLI but keeping --printerClass too would be ideal.

anavarre’s picture

Also, is this still relevant?

TODO set printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter" once https://youtrack.jetbrains.com/issue/WI-24808 is resolved.

rfay’s picture

--printerClass is not a valid phpunit option at all. I agree that it *ought to* be. But removing a reference to an invalid option is a *good* thing. Only --printer= should be mentioned, but printerClass= for the phpunit.xml.dist option.

AFAICT, the printerClass definition works, and does not break PHPStorm any more. 2016.3 EAP, October 19, 2016. Here's what I put in there:

<phpunit bootstrap="tests/bootstrap.php" colors="true"
         beStrictAboutTestsThatDoNotTestAnything="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutChangesToGlobalState="true"
         checkForUnintentionallyCoveredCode="false"
         printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter"
>

Here's the results:

$ vendor/phpunit/phpunit/phpunit -c core/phpunit.xml  modules/examples/phpunit_example

PHPUnit 4.8.27 by Sebastian Bergmann and contributors.

...................................

Time: 27.32 seconds, Memory: 4.75Mb

OK (35 tests, 55 assertions)

HTML output was generated
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-54-55271014.html
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-55-55271014.html
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-56-55271014.html
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-57-55271014.html
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-58-55271014.html
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-59-55271014.html
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-60-55271014.html
http://d8git.dev/sites/simpletest/browser_output/Drupal_Tests_phpunit_example_Functional_ExampleFunctionalTest-61-55271014.html
klausi’s picture

Status: Needs work » Reviewed & tested by the community

Thanks for researching this, so the patch from #5 is correct.

printerClass is still mentioned in phpunit.xml.dist as config option, while --printer should be used on the CLI. The comments in phpunit.xml.dist even explain it sufficiently.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 2811065-3.patch, failed testing.

klausi’s picture

Status: Needs work » Reviewed & tested by the community

Random test fail, queued for testing again. Back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 4bbbcd6 to 8.3.x and 8cc46e6 to 8.2.x. Thanks!

It'd be great to open an issue to explore @rfay's finding to see if we can always have the printer on.

  • alexpott committed 4bbbcd6 on 8.3.x
    Issue #2811065 by webflo, klausi, anavarre, tstoeckler, rfay: Fix docs...

  • alexpott committed 8cc46e6 on 8.2.x
    Issue #2811065 by webflo, klausi, anavarre, tstoeckler, rfay: Fix docs...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jibran’s picture