14
14
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
15
15
use Magento \GraphQl \Model \Query \ContextExtensionInterface ;
16
16
use Magento \Wishlist \Model \Wishlist ;
17
+ use Magento \Wishlist \Model \Wishlist \Config ;
17
18
use Magento \Wishlist \Model \WishlistFactory ;
18
19
use Magento \WishlistGraphQl \Model \Resolver \CustomerWishlistResolver ;
19
20
use PHPUnit \Framework \MockObject \MockObject ;
@@ -48,6 +49,11 @@ class CustomerWishlistResolverTest extends TestCase
48
49
*/
49
50
private $ resolver ;
50
51
52
+ /**
53
+ * @var Config|MockObject
54
+ */
55
+ private $ wishlistConfigMock ;
56
+
51
57
/**
52
58
* Build the Testing Environment
53
59
*/
@@ -74,9 +80,14 @@ protected function setUp(): void
74
80
->setMethods (['loadByCustomerId ' , 'getId ' , 'getSharingCode ' , 'getUpdatedAt ' , 'getItemsCount ' ])
75
81
->getMock ();
76
82
83
+ $ this ->wishlistConfigMock = $ this ->createMock (Config::class);
84
+
85
+ $ this ->wishlistConfigMock = $ this ->getMockClass ();
86
+
77
87
$ objectManager = new ObjectManager ($ this );
78
88
$ this ->resolver = $ objectManager ->getObject (CustomerWishlistResolver::class, [
79
- 'wishlistFactory ' => $ this ->wishlistFactoryMock
89
+ 'wishlistFactory ' => $ this ->wishlistFactoryMock ,
90
+ 'wishlistConfig ' => $ this ->wishlistConfigMock
80
91
]);
81
92
}
82
93
@@ -85,6 +96,8 @@ protected function setUp(): void
85
96
*/
86
97
public function testThrowExceptionWhenUserNotAuthorized (): void
87
98
{
99
+ $ this ->wishlistConfigMock ->method ('isEnabled ' )->willReturn (true );
100
+
88
101
// Given
89
102
$ this ->extensionAttributesMock ->method ('getIsCustomer ' )
90
103
->willReturn (false );
@@ -107,6 +120,8 @@ public function testThrowExceptionWhenUserNotAuthorized(): void
107
120
*/
108
121
public function testFactoryCreatesWishlistByAuthorizedCustomerId (): void
109
122
{
123
+ $ this ->wishlistConfigMock ->method ('isEnabled ' )->willReturn (true );
124
+
110
125
// Given
111
126
$ this ->extensionAttributesMock ->method ('getIsCustomer ' )
112
127
->willReturn (true );
0 commit comments