Skip to content

Commit 58215aa

Browse files
committed
Fixing Unit Test
1 parent c988ab2 commit 58215aa

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

app/code/Magento/WishlistGraphQl/Test/Unit/CustomerWishlistResolverTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1515
use Magento\GraphQl\Model\Query\ContextExtensionInterface;
1616
use Magento\Wishlist\Model\Wishlist;
17+
use Magento\Wishlist\Model\Wishlist\Config;
1718
use Magento\Wishlist\Model\WishlistFactory;
1819
use Magento\WishlistGraphQl\Model\Resolver\CustomerWishlistResolver;
1920
use PHPUnit\Framework\MockObject\MockObject;
@@ -48,6 +49,11 @@ class CustomerWishlistResolverTest extends TestCase
4849
*/
4950
private $resolver;
5051

52+
/**
53+
* @var Config|MockObject
54+
*/
55+
private $wishlistConfigMock;
56+
5157
/**
5258
* Build the Testing Environment
5359
*/
@@ -74,9 +80,14 @@ protected function setUp(): void
7480
->setMethods(['loadByCustomerId', 'getId', 'getSharingCode', 'getUpdatedAt', 'getItemsCount'])
7581
->getMock();
7682

83+
$this->wishlistConfigMock = $this->createMock(Config::class);
84+
85+
$this->wishlistConfigMock = $this->getMockClass();
86+
7787
$objectManager = new ObjectManager($this);
7888
$this->resolver = $objectManager->getObject(CustomerWishlistResolver::class, [
79-
'wishlistFactory' => $this->wishlistFactoryMock
89+
'wishlistFactory' => $this->wishlistFactoryMock,
90+
'wishlistConfig' => $this->wishlistConfigMock
8091
]);
8192
}
8293

@@ -85,6 +96,8 @@ protected function setUp(): void
8596
*/
8697
public function testThrowExceptionWhenUserNotAuthorized(): void
8798
{
99+
$this->wishlistConfigMock->method('isEnabled')->willReturn(true);
100+
88101
// Given
89102
$this->extensionAttributesMock->method('getIsCustomer')
90103
->willReturn(false);
@@ -107,6 +120,8 @@ public function testThrowExceptionWhenUserNotAuthorized(): void
107120
*/
108121
public function testFactoryCreatesWishlistByAuthorizedCustomerId(): void
109122
{
123+
$this->wishlistConfigMock->method('isEnabled')->willReturn(true);
124+
110125
// Given
111126
$this->extensionAttributesMock->method('getIsCustomer')
112127
->willReturn(true);

0 commit comments

Comments
 (0)