Sylius load sample data Command tests

This commit is contained in:
Magdalena Banasiak 2016-02-23 16:00:09 +01:00
parent 2f219a1811
commit 69516c54bd
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,11 @@
@installer @cli
Feature: Load sample data feature
In order to have sample data in Sylius
As a Developer
I want to run a command that loads sample data
Scenario: Running install sample data command
Given I run Sylius Install Load Sample Data command
And I confirm loading sample data
Then I should see output "Loading sample data..."
And the command should finish successfully

View file

@ -12,6 +12,7 @@
namespace Sylius\Behat\Context\Cli; namespace Sylius\Behat\Context\Cli;
use Behat\Behat\Context\Context; use Behat\Behat\Context\Context;
use Sylius\Bundle\InstallerBundle\Command\InstallSampleDataCommand;
use Sylius\Bundle\InstallerBundle\Command\SetupCommand; use Sylius\Bundle\InstallerBundle\Command\SetupCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Helper\DialogHelper; use Symfony\Component\Console\Helper\DialogHelper;
@ -83,6 +84,33 @@ final class InstallerContext implements Context
$this->iExecuteCommandWithInputChoices('sylius:install:setup'); $this->iExecuteCommandWithInputChoices('sylius:install:setup');
} }
/**
* @Given I run Sylius Install Load Sample Data command
*/
public function iRunSyliusInstallSampleDataCommand()
{
$this->application = new Application($this->kernel);
$this->application->add(new InstallSampleDataCommand());
$this->command = $this->application->find('sylius:install:sample-data');
$this->tester = new CommandTester($this->command);
}
/**
* @Given I confirm loading sample data
*/
public function iConfirmLoadingData()
{
$this->iExecuteCommandAndConfirm('sylius:install:sample-data');
}
/**
* @Then the command should finish successfully
*/
public function commandSuccess()
{
expect($this->tester->getStatusCode())->toBe(0);
}
/** /**
* @Then I should see output :text * @Then I should see output :text
*/ */
@ -177,4 +205,17 @@ final class InstallerContext implements Context
$this->tester->execute($fullParameters); $this->tester->execute($fullParameters);
} }
/**
* @param string $name
*/
private function iExecuteCommandAndConfirm($name)
{
$fullParameters = array_merge(array('command' => $name));
$this->dialog = $this->command->getHelper('dialog');
$inputString = 'y'.PHP_EOL;
$this->dialog->setInputStream($this->getInputStream($inputString));
$this->tester->execute($fullParameters);
}
} }