Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7239 from NeverResponse/archive/shipping-methods
[Admin] Archiving shipping methods
- Loading branch information
Showing
46 changed files
with
1,147 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Sylius\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
class Version20161223164558 extends AbstractMigration | ||
{ | ||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function up(Schema $schema) | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE sylius_shipping_method ADD archived_at DATETIME DEFAULT NULL'); | ||
} | ||
|
||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function down(Schema $schema) | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('ALTER TABLE sylius_shipping_method DROP archived_at'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
features/shipping/managing_shipping_methods/archiving_shipping_methods.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@managing_shipping_methods | ||
Feature: Archiving obsolete shipping methods | ||
In order to hide no longer available shipping methods from the list and customers' use | ||
As an Administrator | ||
I want to archive shipping methods | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store allows shipping with "UPS Carrier" and "FedEx Carrier" | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Archiving a shipping method | ||
Given I am browsing shipping methods | ||
When I archive the "UPS Carrier" shipping method | ||
Then the only shipping method on the list should be "FedEx Carrier" | ||
|
||
@domain | ||
Scenario: Archiving a shipping method does not remove it from the database | ||
When I archive the "UPS Carrier" shipping method | ||
Then the shipping method "UPS Carrier" should still exist in the registry | ||
|
||
@ui | ||
Scenario: Seeing only archived shipping methods | ||
Given the shipping method "UPS Carrier" is archival | ||
And I am browsing shipping methods | ||
When I filter archival shipping methods | ||
Then the only shipping method on the list should be "UPS Carrier" | ||
|
||
@ui | ||
Scenario: Restoring an archival shipping method | ||
Given the shipping method "UPS Carrier" is archival | ||
And I am browsing archival shipping methods | ||
When I restore the "UPS Carrier" shipping method | ||
Then I should be viewing non archival shipping methods | ||
And I should see 2 shipping methods on the list |
62 changes: 62 additions & 0 deletions
62
src/Sylius/Behat/Context/Domain/ManagingShippingMethodsContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?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. | ||
*/ | ||
|
||
namespace Sylius\Behat\Context\Domain; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Sylius\Component\Resource\Repository\RepositoryInterface; | ||
use Sylius\Component\Shipping\Model\ShippingMethodInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @author Jan Góralski <jan.goralski@lakion.com> | ||
*/ | ||
final class ManagingShippingMethodsContext implements Context | ||
{ | ||
/** | ||
* @var RepositoryInterface | ||
*/ | ||
private $shippingMethodRepository; | ||
|
||
/** | ||
* @var ObjectManager | ||
*/ | ||
private $shippingMethodManager; | ||
|
||
/** | ||
* @param RepositoryInterface $shippingMethodRepository | ||
* @param ObjectManager $shippingMethodManager | ||
*/ | ||
public function __construct(RepositoryInterface $shippingMethodRepository, ObjectManager $shippingMethodManager) | ||
{ | ||
$this->shippingMethodRepository = $shippingMethodRepository; | ||
$this->shippingMethodManager = $shippingMethodManager; | ||
} | ||
|
||
/** | ||
* @When /^I archive the ("[^"]+" shipping method)$/ | ||
*/ | ||
public function iArchiveTheShippingMethod(ShippingMethodInterface $shippingMethod) | ||
{ | ||
$shippingMethod->setArchivedAt(new \DateTime()); | ||
|
||
$this->shippingMethodManager->flush(); | ||
} | ||
|
||
/** | ||
* @Then the shipping method :shippingMethod should still exist in the registry | ||
*/ | ||
public function theShippingMethodShouldStillExistInTheRegistry(ShippingMethodInterface $shippingMethod) | ||
{ | ||
Assert::notNull($this->shippingMethodRepository->find($shippingMethod)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.