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 #7227 from David-Guillot/fix/gh7211-should-not-be-…
…able-to-delete-used-payment-method Fixed #7211: now can't delete a used PaymentMethod
- Loading branch information
Showing
6 changed files
with
96 additions
and
2 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,36 @@ | ||
<?php | ||
|
||
namespace Sylius\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
class Version20170110120125 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_payment DROP FOREIGN KEY FK_D9191BD419883967'); | ||
$this->addSql('ALTER TABLE sylius_payment ADD CONSTRAINT FK_D9191BD419883967 FOREIGN KEY (method_id) REFERENCES sylius_payment_method (id)'); | ||
} | ||
|
||
/** | ||
* @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_payment DROP FOREIGN KEY FK_D9191BD419883967'); | ||
$this->addSql('ALTER TABLE sylius_payment ADD CONSTRAINT FK_D9191BD419883967 FOREIGN KEY (method_id) REFERENCES sylius_payment_method (id) ON DELETE SET NULL'); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
features/payment/managing_payment_methods/preventing_deletion_of_used_payment_method.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,21 @@ | ||
@managing_payment_methods | ||
Feature: Prevent deletion of used payment method | ||
In order to maintain proper order history | ||
As an Administrator | ||
I want to be prevented from deleting used payment method | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has a product "PHP T-Shirt" | ||
And the store allows shipping with "DHL Express" | ||
And the store allows paying with "Cash on Delivery" | ||
And there is a customer "john.doe@gmail.com" that placed an order "#00000022" | ||
And the customer bought a single "PHP T-Shirt" | ||
And the customer chose "DHL Express" shipping method to "United States" with "Cash on Delivery" payment | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Being unable to delete a payment method which is in use | ||
When I try to delete the "Cash on Delivery" payment method | ||
Then I should be notified that it is in use | ||
And this payment method should still be in the registry |
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