11

I'm doing some overloading to PHPUnit's Selenium extension that uses the CaptureEntirePageScreenshotToString function, and I would like to only print the path to the screenshot as we go only when --verbose or --debug is passed in.

For instance, phpunit --debug ./tests

Then somewhere in my code I have (this is psudo code)

if (--debug)
  echo "Screenshot: /path/to/screenshot.png

Suggestions?

edorian
  • 38,542
  • 15
  • 125
  • 143
General Redneck
  • 1,240
  • 2
  • 13
  • 28

1 Answers1

18

There is no PHPUnit internal API to do this. The configuration object is not accessible through the test cases directly.

You can't use PHPUnit_Util_Configuration::getInstance() as thats only the wrapper for the xml config.

My suggestion would be to just use:

if(in_array('--debug', $_SERVER['argv'], true)) {
     //Insert your debug code here.
}

Relevant classes:

kenorb
  • 155,785
  • 88
  • 678
  • 743
edorian
  • 38,542
  • 15
  • 125
  • 143