Skip to content

Commit 1349e98

Browse files
author
Anna Bukatar
committed
ACP2E-1875: Products incorrectly showed Out of Stock then all products show in stock
1 parent 121d774 commit 1349e98

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportExport\Test\Unit\Plugin;
9+
10+
use Magento\Framework\Indexer\DeferredCacheCleanerInterface;
11+
use Magento\ImportExport\Model\Import;
12+
use Magento\ImportExport\Plugin\DeferCacheCleaningUntilImportIsComplete;
13+
use PHPUnit\Framework\MockObject\MockObject;
14+
use PHPUnit\Framework\TestCase;
15+
16+
class DeferCacheCleaningUntilImportIsCompleteTest extends TestCase
17+
{
18+
/**
19+
* @var DeferCacheCleaningUntilImportIsComplete
20+
*/
21+
private $plugin;
22+
23+
/**
24+
* @var DeferredCacheCleanerInterface|MockObject
25+
*/
26+
private $cacheCleaner;
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
protected function setUp(): void
32+
{
33+
parent::setUp();
34+
$this->cacheCleaner = $this->getMockForAbstractClass(DeferredCacheCleanerInterface::class);
35+
$this->plugin = new DeferCacheCleaningUntilImportIsComplete($this->cacheCleaner);
36+
}
37+
38+
/**
39+
* @return void
40+
*/
41+
public function testBeforeMethod()
42+
{
43+
$this->cacheCleaner->expects($this->once())->method('start');
44+
$subject = $this->createMock(Import::class);
45+
$this->plugin->beforeImportSource($subject);
46+
}
47+
48+
/**
49+
* @return void
50+
*/
51+
public function testAfterMethod()
52+
{
53+
$this->cacheCleaner->expects($this->once())->method('flush');
54+
$subject = $this->createMock(Import::class);
55+
$result = $this->plugin->afterImportSource($subject, true);
56+
$this->assertTrue($result);
57+
}
58+
}

0 commit comments

Comments
 (0)