mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Sylius load sample data Command tests
This commit is contained in:
parent
2f219a1811
commit
69516c54bd
2 changed files with 52 additions and 0 deletions
11
features/installer/load_sample_data_command.feature
Normal file
11
features/installer/load_sample_data_command.feature
Normal 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
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue