-
-
Notifications
You must be signed in to change notification settings - Fork 157
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 #1254 from dpfaffenbauer/issue/recycle-bin
[CoreExtensions] fix issue with CoreShop CoreExtensions Recycle Bin
- Loading branch information
Showing
15 changed files
with
379 additions
and
7 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,22 @@ | ||
@recycle_bin @recycle_bin_store_values | ||
Feature: In order to support Pimcore Recycle Bin, we have to serialize Store Values and merge them back | ||
|
||
Background: | ||
Given the site operates on a store in "Austria" | ||
And the site has a country "Germany" with currency "EUR" | ||
And the site has a store "Germany" with country "Germany" and currency "EUR" | ||
And the site operates on locale "en" | ||
And the site has a product "Shoe" priced at 100 | ||
And the products price is 100 for store "Austria" | ||
And the products price is 200 for store "Germany" | ||
|
||
Scenario: Change Prices | ||
Given I recycle the product | ||
Then the recycled product does not exist anymore | ||
Given I restore the recycled product | ||
|
||
Then I am in store "Austria" | ||
And the product should be priced at "100" | ||
|
||
Then I am in store "Germany" | ||
And the product should be priced at "200" |
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,43 @@ | ||
<?php | ||
/** | ||
* CoreShop. | ||
* | ||
* This source file is subject to the GNU General Public License version 3 (GPLv3) | ||
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt | ||
* files that are distributed with this source code. | ||
* | ||
* @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) | ||
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) | ||
*/ | ||
|
||
namespace CoreShop\Behat\Context\Domain; | ||
|
||
use Behat\Behat\Context\Context; | ||
use CoreShop\Behat\Service\SharedStorageInterface; | ||
use Pimcore\Model\DataObject; | ||
use Pimcore\Model\DataObject\Concrete; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class RecycleBinContext implements Context | ||
{ | ||
/** | ||
* @var SharedStorageInterface | ||
*/ | ||
private $sharedStorage; | ||
|
||
/** | ||
* @param SharedStorageInterface $sharedStorage | ||
*/ | ||
public function __construct(SharedStorageInterface $sharedStorage) | ||
{ | ||
$this->sharedStorage = $sharedStorage; | ||
} | ||
|
||
/** | ||
* @Then /^the recycled (product) does not exist anymore$/ | ||
*/ | ||
public function theRecycledProductDoesNotExistAnymore(Concrete $concrete) | ||
{ | ||
Assert::null(DataObject::getById($concrete->getId(), true)); | ||
} | ||
} |
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,92 @@ | ||
<?php | ||
/** | ||
* CoreShop. | ||
* | ||
* This source file is subject to the GNU General Public License version 3 (GPLv3) | ||
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt | ||
* files that are distributed with this source code. | ||
* | ||
* @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at) | ||
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3) | ||
*/ | ||
|
||
namespace CoreShop\Behat\Context\Setup; | ||
|
||
use Behat\Behat\Context\Context; | ||
use CoreShop\Behat\Service\SharedStorageInterface; | ||
use CoreShop\Component\Address\Model\ZoneInterface; | ||
use CoreShop\Component\Core\Model\ProductInterface; | ||
use CoreShop\Component\Pimcore\DataObject\VersionHelper; | ||
use CoreShop\Component\Resource\Factory\FactoryInterface; | ||
use CoreShop\Component\Resource\Repository\RepositoryInterface; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Pimcore\Model\DataObject; | ||
use Pimcore\Model\DataObject\Concrete; | ||
use Pimcore\Model\Element\Recyclebin\Item; | ||
use Pimcore\Model\User; | ||
use Pimcore\Model\Version; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class RecycleBinContext implements Context | ||
{ | ||
/** | ||
* @var SharedStorageInterface | ||
*/ | ||
private $sharedStorage; | ||
|
||
/** | ||
* @param SharedStorageInterface $sharedStorage | ||
*/ | ||
public function __construct( | ||
SharedStorageInterface $sharedStorage | ||
) { | ||
$this->sharedStorage = $sharedStorage; | ||
} | ||
|
||
/** | ||
* @Then /^I recycle the (product "[^"]+")$/ | ||
* @Then /^I recycle the (product)$/ | ||
*/ | ||
public function IAddTheObjectToTheBin(Concrete $concrete) | ||
{ | ||
/** | ||
* @var Item $item | ||
*/ | ||
$item = new Item(); | ||
$item->setElement($concrete); | ||
$item->save(); | ||
|
||
$concrete->delete(); | ||
|
||
$this->sharedStorage->set( | ||
'data_object_recycle_' . $concrete->getId(), | ||
$item->getId() | ||
); | ||
} | ||
|
||
/** | ||
* @Then /^I restore the recycled (product "[^"]+")$/ | ||
* @Then /^I restore the recycled (product)$/ | ||
*/ | ||
public function iRestoreTheRecycledProduct(Concrete $concrete) | ||
{ | ||
$key = 'data_object_recycle_' . $concrete->getId(); | ||
|
||
/** | ||
* @var Item $item | ||
*/ | ||
$item = Item::getById($this->sharedStorage->get($key)); | ||
|
||
Assert::isInstanceOf($item, Item::class); | ||
|
||
$item->restore(); | ||
|
||
$product = DataObject::getById($concrete->getId(), true); | ||
|
||
|
||
Assert::isInstanceOf($product, ProductInterface::class); | ||
|
||
//Force reload of restored product | ||
$this->sharedStorage->set('product', $product); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/CoreShop/Behat/Resources/config/suites/domain/recycle_bin.yml
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,45 @@ | ||
default: | ||
suites: | ||
domain_product: | ||
contexts: | ||
- coreshop.behat.context.hook.pimcore_setup | ||
- coreshop.behat.context.hook.coreshop_setup | ||
|
||
- coreshop.behat.context.hook.doctrine_orm | ||
- coreshop.behat.context.hook.pimcore_dao | ||
|
||
- coreshop.behat.context.transform.shared_storage | ||
- coreshop.behat.context.transform.product | ||
- coreshop.behat.context.transform.product_price_rule | ||
- coreshop.behat.context.transform.product_specific_price_rule | ||
- coreshop.behat.context.transform.category | ||
- coreshop.behat.context.transform.country | ||
- coreshop.behat.context.transform.currency | ||
- coreshop.behat.context.transform.customer | ||
- coreshop.behat.context.transform.customer_group | ||
- coreshop.behat.context.transform.zone | ||
- coreshop.behat.context.transform.store | ||
- coreshop.behat.context.transform.tax_rate | ||
- coreshop.behat.context.transform.tax_rule_group | ||
- coreshop.behat.context.transform.product_unit | ||
|
||
- coreshop.behat.context.setup.product | ||
- coreshop.behat.context.setup.locale | ||
- coreshop.behat.context.setup.product_price_rule | ||
- coreshop.behat.context.setup.product_specific_price_rule | ||
- coreshop.behat.context.setup.store | ||
- coreshop.behat.context.setup.category | ||
- coreshop.behat.context.setup.country | ||
- coreshop.behat.context.setup.currency | ||
- coreshop.behat.context.setup.customer | ||
- coreshop.behat.context.setup.customer_group | ||
- coreshop.behat.context.setup.zone | ||
- coreshop.behat.context.setup.tax_rate | ||
- coreshop.behat.context.setup.tax_rule_group | ||
- coreshop.behat.context.setup.product_unit | ||
- coreshop.behat.context.setup.recycle_bin | ||
|
||
- coreshop.behat.context.domain.product | ||
- coreshop.behat.context.domain.recycle_bin | ||
filters: | ||
tags: "@recycle_bin" |
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.