Reputation: 5166
I am implementing some Integration tests by using unit testing. I am using the setUp()
method to set a config file. My config file consists of some Api keys
API secret
etc. This is working good.
public function setUp()
{
$this->_pipeline = new Pipline($this);
$this->_pipeline->setConfig(\Api\Models\ConfigModel::createFromFile(__DIR__ . '/test/integration/assets/config'));
$users = $this->_pipeline->users->listUsers();
$this->_userId = $users->result->data[0]->user_id;
parent::setUp();
}
This method is working good in this way.
Problem But I want to pass the config file from command. Currently i am using this command
php ./vendor/phpunit/phpunit/phpunit -c ./test/integration/phpunit.xml
Is there a way i can pass this from command something like this
php ./vendor/phpunit/phpunit/phpunit -c ./test/integration/phpunit.xml -c2 /test/integration/assets/config
Thanks in advance.
Upvotes: 0
Views: 1061
Reputation: 147206
You could just pass the name as an argument to php:
php ./vendor/phpunit/phpunit/phpunit -c ./test/integration/phpunit.xml -- /test/integration/assets/config
You can access the arguments via $argc
and $argv
; $argv[0]
is the name of the script, so your config file name will be in $argv[1]
.
e.g.
E:\>php -r "echo \"$argc\n\"; print_r($argv);" -- "hello world!"
2
Array
(
[0] => -
[1] => hello world!
)
Upvotes: 1