14
14
use Magento \ConfigurableProduct \Plugin \CatalogWidget \Block \Product \ProductsListPlugin ;
15
15
use Magento \Framework \App \ResourceConnection ;
16
16
use Magento \Framework \DB \Adapter \AdapterInterface ;
17
+ use Magento \Framework \EntityManager \EntityMetadataInterface ;
18
+ use Magento \Framework \EntityManager \MetadataPool ;
17
19
use PHPUnit \Framework \TestCase ;
18
20
use PHPUnit \Framework \MockObject \MockObject ;
19
21
use Magento \Framework \DB \Select ;
@@ -36,6 +38,11 @@ class ProductListPluginTest extends TestCase
36
38
*/
37
39
protected ResourceConnection $ resource ;
38
40
41
+ /**
42
+ * @var MetadataPool
43
+ */
44
+ protected MetadataPool $ metadataPool ;
45
+
39
46
/**
40
47
* @var ProductsListPlugin
41
48
*/
@@ -46,11 +53,13 @@ protected function setUp(): void
46
53
$ this ->productCollectionFactory = $ this ->createMock (CollectionFactory::class);
47
54
$ this ->catalogProductVisibility = $ this ->createMock (Visibility::class);
48
55
$ this ->resource = $ this ->createMock (ResourceConnection::class);
56
+ $ this ->metadataPool = $ this ->createMock (MetadataPool::class);
49
57
50
58
$ this ->plugin = new ProductsListPlugin (
51
59
$ this ->productCollectionFactory ,
52
60
$ this ->catalogProductVisibility ,
53
- $ this ->resource
61
+ $ this ->resource ,
62
+ $ this ->metadataPool
54
63
);
55
64
56
65
parent ::setUp ();
@@ -80,6 +89,12 @@ public function testAfterCreateCollectionSuccess(): void
80
89
$ result ->expects ($ this ->once ())->method ('count ' )->willReturn (1 );
81
90
$ result ->expects ($ this ->once ())->method ('getAllIds ' )->willReturn ([1 ]);
82
91
$ 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 );
83
98
84
99
$ select = $ this ->createMock (Select::class);
85
100
$ select ->expects ($ this ->once ())
@@ -90,7 +105,7 @@ public function testAfterCreateCollectionSuccess(): void
90
105
->method ('joinInner ' )
91
106
->with (
92
107
['link_table ' => 'catalog_product_super_link ' ],
93
- 'link_table.product_id = e.entity_id ' ,
108
+ 'link_table.product_id = e.row_id ' ,
94
109
[]
95
110
)->willReturn ($ select );
96
111
$ select ->expects ($ this ->once ())->method ('where ' )->with ('link_table.product_id IN (?) ' , [1 ]);
0 commit comments