Reputation: 1162
I'm working on laravel 5 app and I need to create an artisan command. I'm using Behat as my testing framework. I know I can test the state of my database inside of behat. I want to run a command like"
php artisan my:command
from inside a behat step. How can I accomplish this?
Thanks
Upvotes: 2
Views: 1197
Reputation: 1162
I found a simple way to do this. Since I'm running an artisan command, I can use the Artisan facade.
/**
* @Given I run the artisan command :command with args :args
* @param $command
* @param $args
*/
public function iRunTheArtisanCommandWithArgs($command, $args)
{
\Artisan::call($command, [$args]);
}
Upvotes: 0
Reputation: 10024
Inside your FeatureContext
class:
/**
* @When I run :command
*/
public function iRun($command)
{
$this->output = shell_exec($command);
}
If you are using Symfony console component, take a look at https://gist.github.com/tPl0ch/6706427
You can even describe your commands like on https://gist.github.com/everzet/1683634.
Upvotes: 4