Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] Add command for showing available Sylius plugins #10004

Merged
merged 4 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Console] Add command for showing available Sylius plugins
  • Loading branch information
GSadee committed Dec 5, 2018
commit 57a4fe057b1e2afb471af27db17264234561991f
72 changes: 72 additions & 0 deletions src/Sylius/Behat/Context/Cli/ShowingAvailablePluginsContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Behat\Context\Cli;

use Behat\Behat\Context\Context;
use Sylius\Bundle\CoreBundle\Command\SetupCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\KernelInterface;
use Webmozart\Assert\Assert;

final class ShowingAvailablePluginsContext implements Context
{
/** @var KernelInterface */
private $kernel;

/** @var Application */
private $application;

/** @var CommandTester */
private $tester;

/** @var SetupCommand */
private $command;

public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
}

/**
* @When I run show available plugins command
*/
public function runShowAvailablePluginsCommand(): void
{
$this->application = new Application($this->kernel);
$this->application->add(new SetupCommand());

$this->command = $this->application->find('sylius:show-available-plugins');
$this->tester = new CommandTester($this->command);

try {
$this->tester->execute(['command' => 'sylius:show-available-plugins']);
} catch (\Exception $e) {
GSadee marked this conversation as resolved.
Show resolved Hide resolved
}
}

/**
* @Then I should see output :output with listed plugins
*/
public function shouldSeeOutputWithListedPlugins(string $output): void
{
Assert::contains($this->tester->getDisplay(), $output);
Assert::contains($this->tester->getDisplay(), 'Admin Order Creation');
Assert::contains($this->tester->getDisplay(), 'Customer Order Cancellation');
Assert::contains($this->tester->getDisplay(), 'Customer Reorder');
Assert::contains($this->tester->getDisplay(), 'Invoicing');
Assert::contains($this->tester->getDisplay(), 'RBAC');
Assert::contains($this->tester->getDisplay(), 'Refund');
}
}
5 changes: 5 additions & 0 deletions src/Sylius/Behat/Resources/config/services/contexts/cli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<services>
<defaults public="true" />

<service id="Sylius\Behat\Context\Cli\ShowingAvailablePluginsContext">
<argument type="service" id="__symfony__.kernel" />
<tag name="fob.context_service" />
</service>

<service id="sylius.behat.context.cli.installer" class="Sylius\Behat\Context\Cli\InstallerContext">
<argument type="service" id="__symfony__.kernel" />
<tag name="fob.context_service" />
Expand Down
2 changes: 2 additions & 0 deletions src/Sylius/Behat/Resources/config/suites.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# This file is part of the Sylius package.
# This file is part of the Sylius package.
GSadee marked this conversation as resolved.
Show resolved Hide resolved
# (c) Paweł Jędrzejewski

imports:
- suites/api/taxon/managing_taxons.yml
- suites/api/product/managing_product_variants.yml

- suites/cli/installer.yml
- suites/cli/showing_available_plugins.yml

- suites/domain/cart/shopping_cart.yml
- suites/domain/order/managing_orders.yml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski

default:
suites:
cli_showing_available_plugins:
contexts_services:
- Sylius\Behat\Context\Cli\ShowingAvailablePluginsContext

filters:
tags: "@showing_available_plugins && @cli"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Bundle\CoreBundle\Command;

use Sylius\Bundle\CoreBundle\Installer\Renderer\TableRenderer;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class ShowAvailablePluginsCommand extends Command
{
protected function configure(): void
{
$this->setName('sylius:show-available-plugins');
$this->setDescription('Shows official Sylius Plugins');
}

protected function execute(InputInterface $input, OutputInterface $output): void
{
$output->writeln('<comment>Available official Sylius Plugins:</comment>');

$pluginTable = new TableRenderer($output);

$pluginTable->setHeaders(['Plugin', 'Description', 'URL']);
$pluginTable->addRow(['<info>Admin Order Creation</info>', 'Creating (and copying) orders in the administration panel.', 'https://github.com/Sylius/AdminOrderCreationPlugin']);
GSadee marked this conversation as resolved.
Show resolved Hide resolved
$pluginTable->addRow(['<info>Customer Order Cancellation</info>', 'Allows customers to quickly cancel their unpaid and unshipped orders.', 'https://github.com/Sylius/CustomerOrderCancellationPlugin']);
$pluginTable->addRow(['<info>Customer Reorder</info>', 'Convenient reordering for the customers from the `My account` section.', 'https://github.com/Sylius/CustomerReorderPlugin']);
$pluginTable->addRow(['<info>Invoicing</info>', 'Automatised, basic invoicing system for orders.', 'https://github.com/Sylius/InvoicingPlugin']);
$pluginTable->addRow(['<info>RBAC</info>', 'Permissions management for the administration panel.', 'https://github.com/Sylius/RBACPlugin']);
$pluginTable->addRow(['<info>Refund</info>', 'Full and partial refunds of items and/or shipping costs including Credit Memos.', 'https://github.com/Sylius/RefundPlugin']);

$pluginTable->render();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
<service id="Sylius\Bundle\CoreBundle\Command\SetupCommand">
<tag name="console.command" />
</service>

<service id="Sylius\Bundle\CoreBundle\Command\ShowAvailablePluginsCommand">
<tag name="console.command" />
</service>
</services>
</container>