7
7
8
8
namespace Magento \ImportExport \Test \Unit \Plugin ;
9
9
10
+ use Magento \Framework \App \Cache \TypeListInterface ;
11
+ use Magento \Framework \App \RequestInterface ;
10
12
use Magento \Framework \Indexer \DeferredCacheCleanerInterface ;
11
13
use Magento \ImportExport \Model \Import ;
12
14
use Magento \ImportExport \Plugin \DeferCacheCleaningUntilImportIsComplete ;
@@ -25,14 +27,30 @@ class DeferCacheCleaningUntilImportIsCompleteTest extends TestCase
25
27
*/
26
28
private $ cacheCleaner ;
27
29
30
+ /**
31
+ * @var TypeListInterface|MockObject
32
+ */
33
+ private $ cacheTypeList ;
34
+
35
+ /**
36
+ * @var RequestInterface|MockObject
37
+ */
38
+ private $ request ;
39
+
28
40
/**
29
41
* @inheritdoc
30
42
*/
31
43
protected function setUp (): void
32
44
{
33
45
parent ::setUp ();
34
46
$ 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
+ );
36
54
}
37
55
38
56
/**
@@ -52,6 +70,11 @@ public function testAfterMethod()
52
70
{
53
71
$ this ->cacheCleaner ->expects ($ this ->once ())->method ('flush ' );
54
72
$ 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
+ ]);
55
78
$ result = $ this ->plugin ->afterImportSource ($ subject , true );
56
79
$ this ->assertTrue ($ result );
57
80
}
0 commit comments