Skip to content

Commit 0417ffc

Browse files
test coverage
1 parent 5099ab7 commit 0417ffc

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,54 @@ public function testRemove()
323323

324324
$this->model->remove();
325325
}
326+
327+
/**
328+
* Test ignored columns for mview specified at the subscription level
329+
*
330+
* @return void
331+
*/
332+
public function testBuildStatementIgnoredColumnSubscriptionLevel(): void
333+
{
334+
$tableName = 'cataloginventory_stock_item';
335+
$ignoredColumnName = 'low_stock_date';
336+
$viewId = 'cataloginventory_stock';
337+
$ignoredData = [
338+
$viewId => [$tableName => [$ignoredColumnName]]
339+
];
340+
341+
$this->connectionMock->expects($this->once())
342+
->method('isTableExists')
343+
->willReturn(true);
344+
$this->connectionMock->expects($this->once())
345+
->method('describeTable')
346+
->willReturn([
347+
'item_id' => ['COLUMN_NAME' => 'item_id'],
348+
'product_id' => ['COLUMN_NAME' => 'product_id'],
349+
'stock_id' => ['COLUMN_NAME' => 'stock_id'],
350+
'qty' => ['COLUMN_NAME' => 'qty'],
351+
$ignoredColumnName => ['COLUMN_NAME' => $ignoredColumnName],
352+
]);
353+
354+
$otherChangelogMock = $this->getMockForAbstractClass(ChangelogInterface::class);
355+
$otherChangelogMock->expects($this->once())
356+
->method('getViewId')
357+
->willReturn($viewId);
358+
359+
$model = new Subscription(
360+
$this->resourceMock,
361+
$this->triggerFactoryMock,
362+
$this->viewCollectionMock,
363+
$this->viewMock,
364+
$tableName,
365+
'columnName',
366+
[],
367+
$ignoredData
368+
);
369+
370+
$method = new \ReflectionMethod($model, 'buildStatement');
371+
$method->setAccessible(true);
372+
$statement = $method->invoke($model, Trigger::EVENT_UPDATE, $otherChangelogMock);
373+
374+
$this->assertStringNotContainsString($ignoredColumnName, $statement);
375+
}
326376
}

0 commit comments

Comments
 (0)