Passing parameters to PHPUnit
You can use PHPUnit's --bootstrap switch for this.
--bootstrap <file> A "bootstrap" PHP file that is run before the tests.
Then, make a bootstrap.php file that contains variables:
$port = 4445;
In your tests, you can grab those values:
global $port;
$this->setPort($port);
Then run:
phpunit --bootstrap boot.php MyTest.php
One way would be for you to inspect $argv and $argc. Something like:
<?php
require_once 'PHPUnit/Framework/TestCase.php';
class EnvironmentTest extends PHPUnit_Framework_TestCase {
public function testHasParam() {
global $argv, $argc;
$this->assertGreaterThan(2, $argc, 'No environment name passed');
$environment = $argv[2];
}
}
Then you can call your phpunittest like this:
phpunit EnvironmentTest.php my-computer