diff --git a/behat.yml.dist b/behat.yml.dist
index 9b722feb5a..b458498097 100644
--- a/behat.yml.dist
+++ b/behat.yml.dist
@@ -3,4 +3,4 @@
imports:
- etc/behat/profiles.yml
- - etc/behat/suites.yml
\ No newline at end of file
+ - etc/behat/suites.yml
diff --git a/etc/behat/services/contexts.xml b/etc/behat/services/contexts.xml
index c06cab14af..21c413197a 100644
--- a/etc/behat/services/contexts.xml
+++ b/etc/behat/services/contexts.xml
@@ -53,6 +53,8 @@
Sylius\Behat\Context\Domain\OrderContext
Sylius\Behat\Context\Domain\PaymentContext
Sylius\Behat\Context\Domain\ShippingContext
+
+ Sylius\Behat\Context\Cli\InstallerContext
@@ -310,5 +312,10 @@
+
+
+
+
+
diff --git a/etc/behat/suites.yml b/etc/behat/suites.yml
index bc2a2e22bc..a796114b72 100644
--- a/etc/behat/suites.yml
+++ b/etc/behat/suites.yml
@@ -39,3 +39,5 @@ imports:
- suites/ui_user.yml
- suites/domain_order.yml
+
+ - suites/cli_installer.yml
diff --git a/etc/behat/suites/cli_installer.yml b/etc/behat/suites/cli_installer.yml
new file mode 100644
index 0000000000..9e3884c38f
--- /dev/null
+++ b/etc/behat/suites/cli_installer.yml
@@ -0,0 +1,13 @@
+# This file is part of the Sylius package.
+# (c) Paweł Jędrzejewski
+
+default:
+ suites:
+ cli_installer:
+ contexts_as_services:
+ - sylius.behat.context.hook.doctrine_orm
+
+ - sylius.behat.context.cli.installer
+
+ filters:
+ tags: @installer && @cli
diff --git a/features/installer/install_command.feature b/features/installer/install_command.feature
index eb6abca39a..8b9ddc2f4c 100644
--- a/features/installer/install_command.feature
+++ b/features/installer/install_command.feature
@@ -1,4 +1,4 @@
-@cli
+@installer @cli
Feature: Sylius Install Feature
In order to install Sylius via CLI
As a Developer
@@ -6,7 +6,7 @@ Feature: Sylius Install Feature
Scenario: Running install setup command
When I run Sylius CLI installer
- Then I should see output "Please enter a currency code (For example "GBP") or press ENTER to use "USD"."
+ Then I should see output "Please enter a currency code"
And I should see output "In which currency can your customers buy goods?"
Scenario: Choosing default currency
diff --git a/src/Sylius/Bundle/InstallerBundle/Behat/CliContext.php b/src/Sylius/Behat/Context/Cli/InstallerContext.php
similarity index 88%
rename from src/Sylius/Bundle/InstallerBundle/Behat/CliContext.php
rename to src/Sylius/Behat/Context/Cli/InstallerContext.php
index 741d09f077..6d6753c5d2 100644
--- a/src/Sylius/Bundle/InstallerBundle/Behat/CliContext.php
+++ b/src/Sylius/Behat/Context/Cli/InstallerContext.php
@@ -9,20 +9,26 @@
* file that was distributed with this source code.
*/
-namespace Sylius\Bundle\InstallerBundle\Behat;
+namespace Sylius\Behat\Context\Cli;
+use Behat\Behat\Context\Context;
use Sylius\Bundle\InstallerBundle\Command\SetupCommand;
-use Sylius\Bundle\ResourceBundle\Behat\DefaultContext;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Helper\DialogHelper;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\HttpKernel\KernelInterface;
/**
* @author Magdalena Banasiak
*/
-class CliContext extends DefaultContext
+final class InstallerContext implements Context
{
+ /**
+ * @var KernelInterface
+ */
+ private $kernel;
+
/**
* @var Application
*/
@@ -55,12 +61,20 @@ class CliContext extends DefaultContext
'confirmation' => ' pswd',
);
+ /**
+ * @param KernelInterface $kernel
+ */
+ public function __construct(KernelInterface $kernel)
+ {
+ $this->kernel = $kernel;
+ }
+
/**
* @When I run Sylius CLI installer
*/
public function iRunSyliusCommandLineInstaller()
{
- $this->application = new Application($this->getKernel());
+ $this->application = new Application($this->kernel);
$this->application->add(new SetupCommand());
$this->command = $this->application->find('sylius:install:setup');
@@ -70,7 +84,7 @@ class CliContext extends DefaultContext
}
/**
- * @Then /^I should see output "(.+)"$/
+ * @Then I should see output :text
*/
public function iShouldSeeOutput($text)
{
diff --git a/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php b/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php
index 3e9eefbe8a..9a61c0a5f5 100644
--- a/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php
+++ b/src/Sylius/Bundle/InstallerBundle/Command/SetupCommand.php
@@ -49,6 +49,7 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupCurrency($input, $output);
+ $this->setupChannel();
$this->setupAdministratorUser($input, $output);
}
@@ -134,21 +135,20 @@ EOT
} while (!$valid);
$code = trim($code);
- $name = Intl::getCurrencyBundle()->getCurrencyName($code);
+ $name = Intl::getCurrencyBundle()->getCurrencyName($code);
$output->writeln(sprintf('Adding %s', $name));
- if (null !== $existingCurrency = $currencyRepository->findOneByCode($code)) {
+ if (null !== $existingCurrency = $currencyRepository->findOneBy(['code' => $code])) {
$this->currency = $existingCurrency;
return;
}
-
$currency = $currencyFactory->createNew();
+ $currency->setExchangeRate(1);
$currency->setBase(true);
$currency->setCode($code);
- $currency->setExchangeRate(1);
$this->currency = $currency;
@@ -156,6 +156,27 @@ EOT
$currencyManager->flush();
}
+ protected function setupChannel()
+ {
+ $channelRepository = $this->get('sylius.repository.channel');
+ $channelManager = $this->get('sylius.manager.channel');
+ $channelFactory = $this->get('sylius.factory.channel');
+
+ $channel = $channelRepository->findOneByCode('DEFAULT');
+
+ if (null !== $channel) {
+ return;
+ }
+
+ $channel = $channelFactory->createNew();
+ $channel->setCode('DEFAULT');
+ $channel->setName('DEFAULT');
+ $channel->setDefaultCurrency($this->currency);
+
+ $channelManager->persist($channel);
+ $channelManager->flush();
+ }
+
/**
* @param InputInterface $input
* @param OutputInterface $output