@@ -49,6 +49,16 @@ class SubscriptionTest extends TestCase
4949 /** @var string */
5050 private $ tableName ;
5151
52+ /**
53+ * @var Config|MockObject
54+ */
55+ private $ mviewConfig ;
56+
57+ /**
58+ * @var DefaultProcessor|MockObject
59+ */
60+ private $ defaultProcessor ;
61+
5262 protected function setUp (): void
5363 {
5464 $ this ->tableName = 'test_table ' ;
@@ -59,17 +69,14 @@ protected function setUp(): void
5969 ->method ('quoteIdentifier ' )
6070 ->willReturnArgument (0 );
6171
62- $ this ->connectionMock ->expects ($ this ->any ())
63- ->method ('describeTable ' )
64- ->willReturn ([]);
65-
72+ $ this ->defaultProcessor = $ this ->createMock (DefaultProcessor::class);
6673 $ this ->resourceMock ->expects ($ this ->atLeastOnce ())
6774 ->method ('getConnection ' )
6875 ->willReturn ($ this ->connectionMock );
6976 ObjectManager::getInstance ()->expects ($ this ->any ())
7077 ->method ('get ' )
7178 ->with (DefaultProcessor::class)
72- ->willReturn (2 );
79+ ->willReturn ($ this -> defaultProcessor );
7380 $ this ->triggerFactoryMock = $ this ->createMock (TriggerFactory::class);
7481 $ this ->viewCollectionMock = $ this ->getMockForAbstractClass (
7582 CollectionInterface::class,
@@ -114,6 +121,7 @@ protected function setUp(): void
114121 $ this ->tableName ,
115122 'columnName ' ,
116123 [],
124+ [],
117125 $ mviewConfigMock
118126 );
119127 }
@@ -367,12 +375,24 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
367375 ]
368376 ]
369377 ];
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+ ]);
370388
371- $ this ->connectionMock ->expects ($ this ->once ())
389+ $ this ->connectionMock ->expects ($ this ->any ())
372390 ->method ('isTableExists ' )
391+ ->with ('cataloginventory_stock_item ' )
373392 ->willReturn (true );
374- $ this ->connectionMock ->expects ($ this ->once ())
393+ $ this ->connectionMock ->expects ($ this ->any ())
375394 ->method ('describeTable ' )
395+ ->with ($ tableName )
376396 ->willReturn ([
377397 'item_id ' => ['COLUMN_NAME ' => 'item_id ' ],
378398 'product_id ' => ['COLUMN_NAME ' => 'product_id ' ],
@@ -383,10 +403,14 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
383403 ]);
384404
385405 $ otherChangelogMock = $ this ->getMockForAbstractClass (ChangelogInterface::class);
386- $ otherChangelogMock ->expects ($ this ->once ())
406+ $ otherChangelogMock ->expects ($ this ->any ())
387407 ->method ('getViewId ' )
388408 ->willReturn ($ viewId );
389409
410+ $ otherChangelogMock ->expects ($ this ->once ())
411+ ->method ('getColumnName ' )
412+ ->willReturn ('entity_id ' );
413+
390414 $ model = new Subscription (
391415 $ this ->resourceMock ,
392416 $ this ->triggerFactoryMock ,
@@ -395,7 +419,8 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
395419 $ tableName ,
396420 'columnName ' ,
397421 [],
398- $ ignoredData
422+ $ ignoredData ,
423+ $ mviewConfigMock
399424 );
400425
401426 $ method = new \ReflectionMethod ($ model , 'buildStatement ' );
0 commit comments