1414use Magento \ConfigurableProduct \Plugin \CatalogWidget \Block \Product \ProductsListPlugin ;
1515use Magento \Framework \App \ResourceConnection ;
1616use Magento \Framework \DB \Adapter \AdapterInterface ;
17+ use Magento \Framework \EntityManager \EntityMetadataInterface ;
18+ use Magento \Framework \EntityManager \MetadataPool ;
1719use PHPUnit \Framework \TestCase ;
1820use PHPUnit \Framework \MockObject \MockObject ;
1921use Magento \Framework \DB \Select ;
@@ -36,6 +38,11 @@ class ProductListPluginTest extends TestCase
3638 */
3739 protected ResourceConnection $ resource ;
3840
41+ /**
42+ * @var MetadataPool
43+ */
44+ protected MetadataPool $ metadataPool ;
45+
3946 /**
4047 * @var ProductsListPlugin
4148 */
@@ -46,11 +53,13 @@ protected function setUp(): void
4653 $ this ->productCollectionFactory = $ this ->createMock (CollectionFactory::class);
4754 $ this ->catalogProductVisibility = $ this ->createMock (Visibility::class);
4855 $ this ->resource = $ this ->createMock (ResourceConnection::class);
56+ $ this ->metadataPool = $ this ->createMock (MetadataPool::class);
4957
5058 $ this ->plugin = new ProductsListPlugin (
5159 $ this ->productCollectionFactory ,
5260 $ this ->catalogProductVisibility ,
53- $ this ->resource
61+ $ this ->resource ,
62+ $ this ->metadataPool
5463 );
5564
5665 parent ::setUp ();
@@ -80,6 +89,12 @@ public function testAfterCreateCollectionSuccess(): void
8089 $ result ->expects ($ this ->once ())->method ('count ' )->willReturn (1 );
8190 $ result ->expects ($ this ->once ())->method ('getAllIds ' )->willReturn ([1 ]);
8291 $ result ->expects ($ this ->once ())->method ('addItem ' );
92+ $ entity = $ this ->createMock (EntityMetadataInterface::class);
93+ $ entity ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ('row_id ' );
94+ $ this ->metadataPool ->expects ($ this ->once ())
95+ ->method ('getMetadata ' )
96+ ->with (\Magento \Catalog \Api \Data \ProductInterface::class)
97+ ->willReturn ($ entity );
8398
8499 $ select = $ this ->createMock (Select::class);
85100 $ select ->expects ($ this ->once ())
@@ -90,7 +105,7 @@ public function testAfterCreateCollectionSuccess(): void
90105 ->method ('joinInner ' )
91106 ->with (
92107 ['link_table ' => 'catalog_product_super_link ' ],
93- 'link_table.product_id = e.entity_id ' ,
108+ 'link_table.product_id = e.row_id ' ,
94109 []
95110 )->willReturn ($ select );
96111 $ select ->expects ($ this ->once ())->method ('where ' )->with ('link_table.product_id IN (?) ' , [1 ]);
0 commit comments