@@ -49,6 +49,16 @@ class SubscriptionTest extends TestCase
49
49
/** @var string */
50
50
private $ tableName ;
51
51
52
+ /**
53
+ * @var Config|MockObject
54
+ */
55
+ private $ mviewConfig ;
56
+
57
+ /**
58
+ * @var DefaultProcessor|MockObject
59
+ */
60
+ private $ defaultProcessor ;
61
+
52
62
protected function setUp (): void
53
63
{
54
64
$ this ->tableName = 'test_table ' ;
@@ -59,17 +69,14 @@ protected function setUp(): void
59
69
->method ('quoteIdentifier ' )
60
70
->willReturnArgument (0 );
61
71
62
- $ this ->connectionMock ->expects ($ this ->any ())
63
- ->method ('describeTable ' )
64
- ->willReturn ([]);
65
-
72
+ $ this ->defaultProcessor = $ this ->createMock (DefaultProcessor::class);
66
73
$ this ->resourceMock ->expects ($ this ->atLeastOnce ())
67
74
->method ('getConnection ' )
68
75
->willReturn ($ this ->connectionMock );
69
76
ObjectManager::getInstance ()->expects ($ this ->any ())
70
77
->method ('get ' )
71
78
->with (DefaultProcessor::class)
72
- ->willReturn (2 );
79
+ ->willReturn ($ this -> defaultProcessor );
73
80
$ this ->triggerFactoryMock = $ this ->createMock (TriggerFactory::class);
74
81
$ this ->viewCollectionMock = $ this ->getMockForAbstractClass (
75
82
CollectionInterface::class,
@@ -114,6 +121,7 @@ protected function setUp(): void
114
121
$ this ->tableName ,
115
122
'columnName ' ,
116
123
[],
124
+ [],
117
125
$ mviewConfigMock
118
126
);
119
127
}
@@ -367,12 +375,24 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
367
375
]
368
376
]
369
377
];
378
+ $ mviewConfigMock = $ this ->createMock (Config::class);
379
+ $ mviewConfigMock ->expects ($ this ->any ())
380
+ ->method ('getView ' )
381
+ ->willReturn ([
382
+ 'subscriptions ' => [
383
+ $ tableName => [
384
+ 'processor ' => DefaultProcessor::class
385
+ ]
386
+ ]
387
+ ]);
370
388
371
- $ this ->connectionMock ->expects ($ this ->once ())
389
+ $ this ->connectionMock ->expects ($ this ->any ())
372
390
->method ('isTableExists ' )
391
+ ->with ('cataloginventory_stock_item ' )
373
392
->willReturn (true );
374
- $ this ->connectionMock ->expects ($ this ->once ())
393
+ $ this ->connectionMock ->expects ($ this ->any ())
375
394
->method ('describeTable ' )
395
+ ->with ($ tableName )
376
396
->willReturn ([
377
397
'item_id ' => ['COLUMN_NAME ' => 'item_id ' ],
378
398
'product_id ' => ['COLUMN_NAME ' => 'product_id ' ],
@@ -383,10 +403,14 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
383
403
]);
384
404
385
405
$ otherChangelogMock = $ this ->getMockForAbstractClass (ChangelogInterface::class);
386
- $ otherChangelogMock ->expects ($ this ->once ())
406
+ $ otherChangelogMock ->expects ($ this ->any ())
387
407
->method ('getViewId ' )
388
408
->willReturn ($ viewId );
389
409
410
+ $ otherChangelogMock ->expects ($ this ->once ())
411
+ ->method ('getColumnName ' )
412
+ ->willReturn ('entity_id ' );
413
+
390
414
$ model = new Subscription (
391
415
$ this ->resourceMock ,
392
416
$ this ->triggerFactoryMock ,
@@ -395,7 +419,8 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
395
419
$ tableName ,
396
420
'columnName ' ,
397
421
[],
398
- $ ignoredData
422
+ $ ignoredData ,
423
+ $ mviewConfigMock
399
424
);
400
425
401
426
$ method = new \ReflectionMethod ($ model , 'buildStatement ' );
0 commit comments