8
8
namespace Magento \WishlistGraphQl \Test \Unit \Model \Resolver ;
9
9
10
10
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
11
+ use Magento \GraphQl \Model \Query \ContextExtensionInterface ;
11
12
use Magento \GraphQl \Model \Query \ContextInterface ;
12
13
use Magento \Framework \GraphQl \Config \Element \Field ;
13
- use Magento \GraphQl \Model \Query \ContextExtensionInterface ;
14
14
use Magento \Store \Api \Data \StoreInterface ;
15
15
use Magento \Store \Model \StoreManagerInterface ;
16
+ use Magento \Store \Model \Website ;
16
17
use Magento \Wishlist \Model \ResourceModel \Item ;
17
18
use Magento \Wishlist \Model \ResourceModel \Item \Collection as WishlistItemCollection ;
18
19
use Magento \Wishlist \Model \ResourceModel \Item \CollectionFactory as WishlistItemCollectionFactory ;
21
22
use PHPUnit \Framework \MockObject \MockObject ;
22
23
use PHPUnit \Framework \TestCase ;
23
24
25
+ /**
26
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
27
+ */
24
28
class WishlistItemsTest extends TestCase
25
29
{
26
30
/**
@@ -49,14 +53,13 @@ protected function setUp(): void
49
53
*/
50
54
public function testResolve (): void
51
55
{
52
- $ storeId = $ itemId = 1 ;
56
+ $ webId = $ storeId = $ itemId = 1 ;
53
57
54
58
$ field = $ this ->createMock (Field::class);
55
- $ context = $ this ->getMockBuilder (ContextInterface::class)
56
- ->disableOriginalConstructor ()
57
- ->getMock ();
59
+ $ context = $ this ->createMock (ContextInterface::class);
58
60
$ 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 );
60
63
61
64
$ extensionAttributes = $ this ->getMockBuilder (ContextExtensionInterface::class)
62
65
->disableOriginalConstructor ()
@@ -87,7 +90,7 @@ public function testResolve(): void
87
90
->willReturnSelf ();
88
91
$ wishlistCollection ->expects ($ this ->once ())
89
92
->method ('addStoreFilter ' )
90
- ->with ($ storeId )
93
+ ->with ([ $ storeId] )
91
94
->willReturnSelf ();
92
95
$ wishlistCollection ->expects ($ this ->once ())->method ('setVisibilityFilter ' )->willReturnSelf ();
93
96
$ wishlistCollection ->expects ($ this ->once ())->method ('setCurPage ' )->willReturnSelf ();
@@ -100,6 +103,10 @@ public function testResolve(): void
100
103
->method ('create ' )
101
104
->willReturn ($ wishlistCollection );
102
105
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
+
103
110
$ resolver = new WishlistItems ($ this ->wishlistItemCollectionFactory , $ this ->storeManager );
104
111
$ resolver ->resolve ($ field , $ context , $ info , ['model ' => $ wishlist ]);
105
112
}
0 commit comments