88namespace Magento \WishlistGraphQl \Test \Unit \Model \Resolver ;
99
1010use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
11+ use Magento \GraphQl \Model \Query \ContextExtensionInterface ;
1112use Magento \GraphQl \Model \Query \ContextInterface ;
1213use Magento \Framework \GraphQl \Config \Element \Field ;
13- use Magento \GraphQl \Model \Query \ContextExtensionInterface ;
1414use Magento \Store \Api \Data \StoreInterface ;
1515use Magento \Store \Model \StoreManagerInterface ;
16+ use Magento \Store \Model \Website ;
1617use Magento \Wishlist \Model \ResourceModel \Item ;
1718use Magento \Wishlist \Model \ResourceModel \Item \Collection as WishlistItemCollection ;
1819use Magento \Wishlist \Model \ResourceModel \Item \CollectionFactory as WishlistItemCollectionFactory ;
2122use PHPUnit \Framework \MockObject \MockObject ;
2223use PHPUnit \Framework \TestCase ;
2324
25+ /**
26+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
27+ */
2428class WishlistItemsTest extends TestCase
2529{
2630 /**
@@ -49,14 +53,13 @@ protected function setUp(): void
4953 */
5054 public function testResolve (): void
5155 {
52- $ storeId = $ itemId = 1 ;
56+ $ webId = $ storeId = $ itemId = 1 ;
5357
5458 $ field = $ this ->createMock (Field::class);
55- $ context = $ this ->getMockBuilder (ContextInterface::class)
56- ->disableOriginalConstructor ()
57- ->getMock ();
59+ $ context = $ this ->createMock (ContextInterface::class);
5860 $ store = $ this ->createMock (StoreInterface::class);
59- $ store ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ storeId );
61+ $ store ->expects ($ this ->once ())->method ('getWebsiteId ' )->willReturn ($ webId );
62+ $ store ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ storeId );
6063
6164 $ extensionAttributes = $ this ->getMockBuilder (ContextExtensionInterface::class)
6265 ->disableOriginalConstructor ()
@@ -87,7 +90,7 @@ public function testResolve(): void
8790 ->willReturnSelf ();
8891 $ wishlistCollection ->expects ($ this ->once ())
8992 ->method ('addStoreFilter ' )
90- ->with ($ storeId )
93+ ->with ([ $ storeId] )
9194 ->willReturnSelf ();
9295 $ wishlistCollection ->expects ($ this ->once ())->method ('setVisibilityFilter ' )->willReturnSelf ();
9396 $ wishlistCollection ->expects ($ this ->once ())->method ('setCurPage ' )->willReturnSelf ();
@@ -100,6 +103,10 @@ public function testResolve(): void
100103 ->method ('create ' )
101104 ->willReturn ($ wishlistCollection );
102105
106+ $ website = $ this ->createMock (Website::class);
107+ $ website ->expects ($ this ->any ())->method ('getStores ' )->willReturn ([$ store ]);
108+ $ this ->storeManager ->expects ($ this ->once ())->method ('getWebsite ' )->with ($ webId )->willReturn ($ website );
109+
103110 $ resolver = new WishlistItems ($ this ->wishlistItemCollectionFactory , $ this ->storeManager );
104111 $ resolver ->resolve ($ field , $ context , $ info , ['model ' => $ wishlist ]);
105112 }
0 commit comments