@@ -44,7 +44,7 @@ public function testGetAssignedProducts()
44
44
{
45
45
$ categoryId = 42 ;
46
46
$ productId = 55 ;
47
- $ productsPosition = [ $ productId => 25 ] ;
47
+ $ position = 25 ;
48
48
$ productSku = 'testSku ' ;
49
49
$ categoryProductLinkMock = $ this ->getMock ('\Magento\Catalog\Api\Data\CategoryProductLinkInterface ' );
50
50
$ categoryMock = $ this ->getMock (
@@ -56,13 +56,14 @@ public function testGetAssignedProducts()
56
56
);
57
57
$ productMock = $ this ->getMock ('\Magento\Catalog\Model\Product ' , [], [], '' , false );
58
58
$ productMock ->expects ($ this ->once ())->method ('getSku ' )->willReturn ($ productSku );
59
+ $ productMock ->expects ($ this ->once ())->method ('getData ' )->with ('cat_index_position ' )->willReturn ($ position );
59
60
$ items = [$ productId => $ productMock ];
60
- $ productsMock = $ this ->getMock ('\ Magento\Framework\Data\Collection\AbstractDb ' , [], [], '' , false );
61
+ $ productsMock = $ this ->getMock ('Magento\Catalog\Model\Resource\Product\Collection ' , [], [], '' , false );
61
62
$ this ->categoryRepositoryMock ->expects ($ this ->once ())->method ('get ' )->with ($ categoryId )
62
63
->willReturn ($ categoryMock );
63
- $ categoryMock ->expects ($ this ->once ())->method ('getProductsPosition ' )->willReturn ($ productsPosition );
64
64
$ categoryMock ->expects ($ this ->once ())->method ('getProductCollection ' )->willReturn ($ productsMock );
65
65
$ categoryMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ categoryId );
66
+ $ productsMock ->expects ($ this ->once ())->method ('addFieldToSelect ' )->with ('position ' )->willReturnSelf ();
66
67
$ productsMock ->expects ($ this ->once ())->method ('getItems ' )->willReturn ($ items );
67
68
$ this ->productLinkFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ categoryProductLinkMock );
68
69
$ categoryProductLinkMock ->expects ($ this ->once ())
@@ -71,7 +72,7 @@ public function testGetAssignedProducts()
71
72
->willReturnSelf ();
72
73
$ categoryProductLinkMock ->expects ($ this ->once ())
73
74
->method ('setPosition ' )
74
- ->with (25 )
75
+ ->with ($ position )
75
76
->willReturnSelf ();
76
77
$ categoryProductLinkMock ->expects ($ this ->once ())
77
78
->method ('setCategoryId ' )
0 commit comments