Skip to content

Commit

Permalink
Merge pull request #8002 from magento-l3/PR_25_NOV_2022
Browse files Browse the repository at this point in the history
L3 bugfix delivery
  • Loading branch information
dhorytskyi authored Dec 12, 2022
2 parents 84e7dfa + e76ca5a commit ea0cf63
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 540 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use Magento\AsynchronousOperations\Model\BulkNotificationManagement;
use Magento\Backend\App\Action\Context;
use Magento\Backend\App\Action;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;

/**
* Class Bulk Notification Dismiss Controller
*/
class Dismiss extends Action implements HttpGetActionInterface
class Dismiss extends Action implements HttpPostActionInterface
{
/**
* @var BulkNotificationManagement
Expand Down Expand Up @@ -56,7 +56,7 @@ public function execute()
$isAcknowledged = $this->notificationManagement->acknowledgeBulks($bulkUuids);

/** @var \Magento\Framework\Controller\Result\Json $result */
$result = $this->resultFactory->create(ResultFactory::TYPE_RAW);
$result = $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData(['']);
if (!$isAcknowledged) {
$result->setHttpResponseCode(400);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Magento\AsynchronousOperations\Model\BulkNotificationManagement;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\Raw;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -44,11 +43,6 @@ class DismissTest extends TestCase
*/
private $jsonResultMock;

/**
* @var MockObject
*/
private $rawResultMock;

protected function setUp(): void
{
$objectManager = new ObjectManager($this);
Expand Down Expand Up @@ -84,10 +78,15 @@ public function testExecute()

$this->resultFactoryMock->expects($this->once())
->method('create')
->with(ResultFactory::TYPE_RAW, [])
->willReturn($this->rawResultMock);
->with(ResultFactory::TYPE_JSON, [])
->willReturn($this->jsonResultMock);

$this->jsonResultMock->expects($this->once())
->method('setData')
->with([''])
->willReturn($this->jsonResultMock);

$this->assertEquals($this->rawResultMock, $this->model->execute());
$this->assertEquals($this->jsonResultMock, $this->model->execute());
}

public function testExecuteSetsBadRequestResponseStatusIfBulkWasNotAcknowledgedCorrectly()
Expand All @@ -101,7 +100,12 @@ public function testExecuteSetsBadRequestResponseStatusIfBulkWasNotAcknowledgedC

$this->resultFactoryMock->expects($this->once())
->method('create')
->with(ResultFactory::TYPE_RAW, [])
->with(ResultFactory::TYPE_JSON, [])
->willReturn($this->jsonResultMock);

$this->jsonResultMock->expects($this->once())
->method('setData')
->with([''])
->willReturn($this->jsonResultMock);

$this->notificationManagementMock->expects($this->once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
use Magento\CatalogInventory\Api\Data\StockStatusInterface;
use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\CatalogInventory\Model\Stock;
use Magento\CatalogInventory\Model\StockStatusApplierInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Select;
use Magento\Framework\App\ObjectManager;

/**
* Generic in-stock status filter
Expand All @@ -32,25 +30,16 @@ class StockStatusFilter implements StockStatusFilterInterface
*/
private $stockConfiguration;

/**
* @var StockStatusApplierInterface
*/
private $stockStatusApplier;

/**
* @param ResourceConnection $resource
* @param StockConfigurationInterface $stockConfiguration
* @param StockStatusApplierInterface|null $stockStatusApplier
*/
public function __construct(
ResourceConnection $resource,
StockConfigurationInterface $stockConfiguration,
?StockStatusApplierInterface $stockStatusApplier = null
StockConfigurationInterface $stockConfiguration
) {
$this->resource = $resource;
$this->stockConfiguration = $stockConfiguration;
$this->stockStatusApplier = $stockStatusApplier
?? ObjectManager::getInstance()->get(StockStatusApplierInterface::class);
}

/**
Expand Down Expand Up @@ -79,13 +68,7 @@ public function execute(
implode(' AND ', $joinCondition),
[]
);

if ($this->stockStatusApplier->hasSearchResultApplier()) {
$select->columns(["{$stockStatusTableAlias}.stock_status AS is_salable"]);
} else {
$select->where("{$stockStatusTableAlias}.stock_status = ?", StockStatusInterface::STATUS_IN_STOCK);
}

$select->where("{$stockStatusTableAlias}.stock_status = ?", StockStatusInterface::STATUS_IN_STOCK);
return $select;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

/**
* Search Result Applier getters and setters
*
* @deprecated - as the implementation has been reverted during the fix of ACP2E-748
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin
*/
class StockStatusApplier implements StockStatusApplierInterface
{
Expand All @@ -23,6 +26,8 @@ class StockStatusApplier implements StockStatusApplierInterface
* Set flag, if the request is originated from SearchResultApplier
*
* @param bool $status
* @deprecated
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
*/
public function setSearchResultApplier(bool $status): void
{
Expand All @@ -33,6 +38,8 @@ public function setSearchResultApplier(bool $status): void
* Get flag, if the request is originated from SearchResultApplier
*
* @return bool
* @deprecated
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
*/
public function hasSearchResultApplier() : bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

/**
* Search Result Applier interface.
*
* @deprecated - as the implementation has been reverted during the fix of ACP2E-748
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin
*/
interface StockStatusApplierInterface
{
Expand All @@ -17,13 +20,17 @@ interface StockStatusApplierInterface
* Set flag, if the request is originated from SearchResultApplier
*
* @param bool $status
* @deprecated
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
*/
public function setSearchResultApplier(bool $status): void;

/**
* Get flag, if the request is originated from SearchResultApplier
*
* @return bool
* @deprecated
* @see \Magento\InventoryCatalog\Plugin\Catalog\Model\ResourceModel\Product\CollectionPlugin::beforeSetOrder
*/
public function hasSearchResultApplier() : bool;
}
Loading

0 comments on commit ea0cf63

Please sign in to comment.