diff --git a/features/installer/load_sample_data_command.feature b/features/installer/load_sample_data_command.feature new file mode 100644 index 0000000000..425189fa27 --- /dev/null +++ b/features/installer/load_sample_data_command.feature @@ -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 diff --git a/src/Sylius/Behat/Context/Cli/InstallerContext.php b/src/Sylius/Behat/Context/Cli/InstallerContext.php index 157e2f8e63..99e9167f0f 100644 --- a/src/Sylius/Behat/Context/Cli/InstallerContext.php +++ b/src/Sylius/Behat/Context/Cli/InstallerContext.php @@ -12,6 +12,7 @@ namespace Sylius\Behat\Context\Cli; use Behat\Behat\Context\Context; +use Sylius\Bundle\InstallerBundle\Command\InstallSampleDataCommand; use Sylius\Bundle\InstallerBundle\Command\SetupCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Helper\DialogHelper; @@ -83,6 +84,33 @@ final class InstallerContext implements Context $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 */ @@ -177,4 +205,17 @@ final class InstallerContext implements Context $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); + } }