Skip to content

Commit ac204ea

Browse files
committed
AC-2797:GraphQL Customer Newsletter Subscriptions are inconsistent in multi website setups - Added mock suffix and fixed unit test failures
1 parent bd033a6 commit ac204ea

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/code/Magento/CustomerGraphQl/Test/Unit/Model/Resolver/IsSubscribedTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class IsSubscribedTest extends TestCase
6363
/**
6464
* @var Subscriber|MockObject
6565
*/
66-
private $subscriber;
66+
private $subscriberMock;
6767

6868
/**
6969
* @var StoreInterface|MockObject
@@ -98,22 +98,25 @@ protected function setUp(): void
9898

9999
$this->contextExtensionMock = $this->getMockBuilder(ContextExtensionInterface::class)
100100
->disableOriginalConstructor()
101+
->onlyMethods(['getStore'])
101102
->getMockForAbstractClass();
102103

103104
$this->customerMock = $this->getMockBuilder(CustomerInterface::class)
104105
->disableOriginalConstructor()
106+
->onlyMethods(['getId'])
105107
->getMockForAbstractClass();
106108

107109
$this->storeMock = $this->getMockBuilder(StoreInterface::class)
108110
->disableOriginalConstructor()
111+
->onlyMethods(['getWebsiteId'])
109112
->getMockForAbstractClass();
110113

111114
$this->fieldMock = $this->getMockBuilder(Field::class)
112115
->disableOriginalConstructor()
113116
->getMock();
114117

115118
$this->subscriberFactory = $this->createMock(SubscriberFactory::class);
116-
$this->subscriber = $this->createMock(Subscriber::class);
119+
$this->subscriberMock = $this->createMock(Subscriber::class);
117120

118121
$this->resolveInfoMock = $this->getMockBuilder(ResolveInfo::class)
119122
->disableOriginalConstructor()
@@ -160,9 +163,9 @@ public function testCustomerIsSubscribed()
160163

161164
$subscriber->expects($this->once())
162165
->method('loadByCustomer')
163-
->willReturn($this->subscriber);
166+
->willReturn($this->subscriberMock);
164167

165-
$this->subscriber->expects($this->once())
168+
$this->subscriberMock->expects($this->once())
166169
->method('isSubscribed')
167170
->willReturn(true);
168171

0 commit comments

Comments
 (0)