Skip to content

Commit

Permalink
Fix #14958 - remove requirement of magento/module-store
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartlomiejsz committed Aug 13, 2019
1 parent 76b2085 commit 11f013c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Magento\Framework\App\ResourceConnection as AppResource;
use Magento\SalesSequence\Model\MetaFactory;
use Magento\SalesSequence\Model\ResourceModel\Meta as ResourceMetadata;
use Magento\Store\Api\Data\StoreInterface;

/**
* Class DeleteByStore
Expand Down Expand Up @@ -50,13 +49,13 @@ public function __construct(
/**
* Deletes all sequence linked entites
*
* @param StoreInterface $store
* @param int $storeId
* @return void
* @throws \Exception
*/
public function execute(StoreInterface $store): void
public function execute($storeId): void
{
$metadataIds = $this->getMetadataIdsByStoreId($store->getId());
$metadataIds = $this->getMetadataIdsByStoreId($storeId);
$profileIds = $this->getProfileIdsByMetadataIds($metadataIds);

$this->appResource->getConnection()->delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function __construct(
*/
public function execute(EventObserver $observer)
{
$this->deleteByStore->execute($observer->getData('store'));
if ($store = $observer->getData('store')) {
$this->deleteByStore->execute($store->getId());
}

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Magento\SalesSequence\Model\MetaFactory;
use Magento\SalesSequence\Model\ResourceModel\Meta as ResourceMeta;
use Magento\SalesSequence\Model\Sequence\DeleteByStore;
use Magento\Store\Api\Data\StoreInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -57,11 +56,6 @@ class DeleteByStoreTest extends TestCase
*/
private $select;

/**
* @var StoreInterface | MockObject
*/
private $store;

protected function setUp()
{
$this->connectionMock = $this->getMockForAbstractClass(
Expand All @@ -85,15 +79,6 @@ protected function setUp()
$this->select = $this->createMock(Select::class);
$this->metaFactory = $this->createPartialMock(MetaFactory::class, ['create']);
$this->metaFactory->expects($this->any())->method('create')->willReturn($this->meta);
$this->store = $this->getMockForAbstractClass(
StoreInterface::class,
[],
'',
false,
false,
true,
['getId']
);

$helper = new ObjectManager($this);
$this->deleteByStore = $helper->getObject(
Expand All @@ -112,9 +97,6 @@ public function testExecute()
$storeId = 1;
$metadataIds = [1, 2];
$profileIds = [10, 11];
$this->store->expects($this->once())
->method('getId')
->willReturn($storeId);
$this->resourceMock->method('getTableName')
->willReturnCallback(static function ($tableName) {
return $tableName;
Expand Down Expand Up @@ -155,6 +137,6 @@ static function ($arg, $arg2) use ($metadataIds, $profileIds) {
$this->resourceSequenceMeta->expects($this->any())
->method('delete')
->willReturn($this->resourceSequenceMeta);
$this->deleteByStore->execute($this->store);
$this->deleteByStore->execute($storeId);
}
}
3 changes: 1 addition & 2 deletions app/code/Magento/SalesSequence/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
},
"require": {
"php": "~7.1.3||~7.2.0",
"magento/framework": "*",
"magento/module-store": "*"
"magento/framework": "*"
},
"type": "magento2-module",
"license": [
Expand Down

0 comments on commit 11f013c

Please sign in to comment.