Skip to content

Commit e342015

Browse files
committed
AC-9569:: [GraphQL Resolver] Customer Resolver Data is Not Invalidated From Import
1 parent 342aad3 commit e342015

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

app/code/Magento/ImportExport/Plugin/DeferCacheCleaningUntilImportIsComplete.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ public function beforeImportSource(Import $subject): void
7070
*/
7171
public function afterImportSource(Import $subject, bool $result): bool
7272
{
73-
$behavior = $this->request->getPost('behavior');
74-
$entity = $this->request->getPost('entity');
75-
$files = $this->request->getFiles();
73+
$behavior = $this->request->getParam('behavior');
74+
$entity = $this->request->getParam('entity');
7675

7776
if ($behavior === self::BEHAVIOR_ADD_UPDATE &&
78-
$entity === self::ENTITY_CUSTOMER &&
79-
!empty($files)) {
77+
$entity === self::ENTITY_CUSTOMER) {
8078
$this->cacheTypeList->cleanType(self::CACHE_TYPE_GRAPHQL_QUERY_RESOLVER_RESULT);
8179
}
8280
$this->cacheCleaner->flush();

app/code/Magento/ImportExport/Test/Unit/Plugin/DeferCacheCleaningUntilImportIsCompleteTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Magento\ImportExport\Test\Unit\Plugin;
99

10+
use Magento\Framework\App\Cache\TypeListInterface;
11+
use Magento\Framework\App\RequestInterface;
1012
use Magento\Framework\Indexer\DeferredCacheCleanerInterface;
1113
use Magento\ImportExport\Model\Import;
1214
use Magento\ImportExport\Plugin\DeferCacheCleaningUntilImportIsComplete;
@@ -25,14 +27,30 @@ class DeferCacheCleaningUntilImportIsCompleteTest extends TestCase
2527
*/
2628
private $cacheCleaner;
2729

30+
/**
31+
* @var TypeListInterface|MockObject
32+
*/
33+
private $cacheTypeList;
34+
35+
/**
36+
* @var RequestInterface|MockObject
37+
*/
38+
private $request;
39+
2840
/**
2941
* @inheritdoc
3042
*/
3143
protected function setUp(): void
3244
{
3345
parent::setUp();
3446
$this->cacheCleaner = $this->getMockForAbstractClass(DeferredCacheCleanerInterface::class);
35-
$this->plugin = new DeferCacheCleaningUntilImportIsComplete($this->cacheCleaner);
47+
$this->cacheTypeList = $this->getMockForAbstractClass(TypeListInterface::class);
48+
$this->request = $this->createMock(RequestInterface::class);
49+
$this->plugin = new DeferCacheCleaningUntilImportIsComplete(
50+
$this->cacheCleaner,
51+
$this->cacheTypeList,
52+
$this->request
53+
);
3654
}
3755

3856
/**
@@ -52,6 +70,11 @@ public function testAfterMethod()
5270
{
5371
$this->cacheCleaner->expects($this->once())->method('flush');
5472
$subject = $this->createMock(Import::class);
73+
// Assuming 'behavior' and 'entity' are the parameter names
74+
$this->request->expects($this->any())->method('getParam')->willReturnMap([
75+
['behavior', null, 'add_update'],
76+
['entity', null, 'customer'],
77+
]);
5578
$result = $this->plugin->afterImportSource($subject, true);
5679
$this->assertTrue($result);
5780
}

0 commit comments

Comments
 (0)