Skip to content

Commit 7c8470c

Browse files
authored
Update NewsletterTest.php
1 parent 3a033f2 commit 7c8470c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/NewsletterTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,39 @@ public function testInitFormCanNotShowTab()
160160

161161
$this->assertSame($this->model, $this->model->initForm());
162162
}
163+
164+
/**
165+
* Test getSubscriberStatusChangedDate
166+
*/
167+
public function testGetSubscriberStatusChangedDate()
168+
{
169+
$customerId = 999;
170+
$websiteId = 1;
171+
$storeId = 1;
172+
$isSubscribed = true;
173+
174+
$this->registryMock->method('registry')->with(RegistryConstants::CURRENT_CUSTOMER_ID)
175+
->willReturn($customerId);
176+
177+
$customer = $this->getMockForAbstractClass(CustomerInterface::class);
178+
$customer->method('getWebsiteId')->willReturn($websiteId);
179+
$customer->method('getStoreId')->willReturn($storeId);
180+
$customer->method('getId')->willReturn($customerId);
181+
$this->customerRepository->method('getById')->with($customerId)->willReturn($customer);
182+
183+
$subscriberMock = $this->getMockBuilder(Subscriber::class)
184+
->disableOriginalConstructor()
185+
->setMethods(['loadByCustomer', 'getChangeStatusAt', 'isSubscribed', 'getData'])
186+
->getMock();
187+
188+
$subscriberMock->method('loadByCustomer')->with($customerId, $websiteId)->willReturnSelf();
189+
$subscriberMock->method('getChangeStatusAt')->willReturn('');
190+
$subscriberMock->method('isSubscribed')->willReturn($isSubscribed);
191+
$subscriberMock->method('getData')->willReturn([]);
192+
$this->subscriberFactoryMock->expects($this->once())->method('create')->willReturn($subscriberMock);
193+
194+
$this->assertEquals('', $this->model->getStatusChangedDate());
195+
}
163196

164197
/**
165198
* Test to initialize the form

0 commit comments

Comments
 (0)