d-_-b
d-_-b

Reputation: 6773

using phpunit command line arguments in my tests/bootstrap/setup/etc

I want to be able to print some config data to stdout from my tests only when I use the '--verbose' phpunit command line argument.

How can I accomplish this?

Upvotes: 4

Views: 3258

Answers (1)

yankee
yankee

Reputation: 40830

Probably this is not really intended by the authors of PHPUnit, but you can do it like this:

<?php

require_once 'PHPUnit/Framework/TestCase.php';

class EnvironmentTest extends PHPUnit_Framework_TestCase
{
    public function testHasParam()
    {
      if (in_array('--verbose', $_SERVER['argv']))
         echo "lots of info";
      else
         echo "no info";
    }
}
?>

Upvotes: 7

Related Questions