-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@cli_wishlist | ||
Feature: Removing guest wishlists | ||
In order to clean guest wishlists | ||
As a developer | ||
I want to be able to delete wishlists created by anonymous customers by running a CLI command | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has a product "Jack Daniels Gentleman" priced at "$10.00" | ||
And all store products appear under a main taxonomy | ||
And I add this product to wishlist | ||
And there are 1 wishlists in the database | ||
|
||
@cli | ||
Scenario: Removing all guest wishlists | ||
Given there is a user "[email protected]" | ||
And user "[email protected]" "sylius" is authenticated | ||
And there are 2 wishlists in the database | ||
When I run delete guest wishlists command | ||
Then the command should succeed | ||
And there are 1 wishlists in the database | ||
|
||
# @cli | ||
# Scenario: Removing guest wishlists with date | ||
# When I run delete guests wishlists command with date "01-01-2024" | ||
# Then the command should succeed | ||
# | ||
# @cli | ||
# Scenario: Removing guest wishlists with invalid date | ||
# When I run delete guests wishlists command with date "invalid" | ||
# Then the command should fail | ||
# And there are 1 wishlists in the database |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\BitBag\SyliusWishlistPlugin\Behat\Context\Cli; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class WishlistContext implements Context | ||
{ | ||
public const REMOVE_GUEST_WISHLISTS_COMMAND = 'bitbag:wishlist:remove-guest-wishlists'; | ||
|
||
private Application $application; | ||
|
||
private ?CommandTester $commandTester = null; | ||
|
||
public function __construct( | ||
KernelInterface $kernel, | ||
) { | ||
$this->application = new Application($kernel); | ||
} | ||
|
||
/** | ||
* @When I run delete guest wishlists command | ||
*/ | ||
public function runRemoveGuestWishlistsCommand(): void | ||
{ | ||
$command = $this->application->find(self::REMOVE_GUEST_WISHLISTS_COMMAND); | ||
|
||
$this->commandTester = new CommandTester($command); | ||
$this->commandTester->execute([]); | ||
} | ||
|
||
/** | ||
* @When I run delete guests wishlists command with date :date | ||
*/ | ||
public function runRemoveGuestWishlistsCommandWithInvalidDate(string $date): void | ||
{ | ||
$command = $this->application->find(self::REMOVE_GUEST_WISHLISTS_COMMAND); | ||
$this->commandTester = new CommandTester($command); | ||
$this->commandTester->execute(['--date' => $date]); | ||
} | ||
|
||
/** | ||
* @When the command should succeed | ||
*/ | ||
public function theCommandShouldSucceed(): void | ||
{ | ||
Assert::same($this->commandTester->getStatusCode(), 0); | ||
Check failure on line 60 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.12.13, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 60 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 60 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter symfony_workflow
Check failure on line 60 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.12.13, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 60 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 60 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter symfony_workflow
|
||
} | ||
|
||
/** | ||
* @When the command should fail | ||
*/ | ||
public function theCommandShouldFail(): void | ||
{ | ||
Assert::same($this->commandTester->getStatusCode(), 1); | ||
Check failure on line 68 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.12.13, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 68 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 68 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^5.4, MySQL 8.0, State Machine Adapter symfony_workflow
Check failure on line 68 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.12.13, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 68 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter winzou_state_machine
Check failure on line 68 in tests/Behat/Context/Cli/WishlistContext.php GitHub Actions / Sylius ~1.13.0, PHP 8.1, Symfony ^6.0, MySQL 8.0, State Machine Adapter symfony_workflow
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\BitBag\SyliusWishlistPlugin\Behat\Context\Common; | ||
|
||
use Behat\Behat\Context\Context; | ||
use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class WishlistContext implements Context | ||
{ | ||
public function __construct(private WishlistRepositoryInterface $wishlistRepository) | ||
{ | ||
} | ||
|
||
/** | ||
* @When there are :count wishlists in the database | ||
*/ | ||
public function thereAreWishlistsInTheDatabase(int $count): void | ||
{ | ||
Assert::same(count($this->wishlistRepository->findAll()), $count); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
imports: | ||
- suites/ui/ui_wishlist.yml | ||
- suites/api/api_wishlist.yml | ||
- suites/cli/cli_wishlist.yml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
default: | ||
suites: | ||
cli_wishlist: | ||
contexts: | ||
- sylius.behat.context.hook.doctrine_orm | ||
- sylius.behat.context.setup.channel | ||
- sylius.behat.context.setup.product | ||
- sylius.behat.context.setup.user | ||
- sylius.behat.context.transform.lexical | ||
- sylius.behat.context.transform.product | ||
- sylius.behat.context.transform.product_variant | ||
- sylius.behat.context.transform.channel | ||
- sylius.behat.context.api.shop.channel | ||
|
||
- bitbag_wishlist_plugin.behat.context.api.wishlist | ||
- bitbag_wishlist_plugin.behat.context.cli.wishlist | ||
- bitbag_wishlist_plugin.behat.context.common.wishlist | ||
- bitbag_sylius_cms_plugin.behat.context.ui.wishlist | ||
- bitbag_sylius_cms_plugin.behat.context.setup.wishlist | ||
|
||
filters: | ||
tags: "@cli_wishlist&&@cli" |