64 private $dataObjectProcessor;
69 private $accountConfirmation;
73 $this->_website = $this->createMock(\
Magento\Store\Model\Website::class);
74 $this->_config = $this->createMock(\
Magento\Eav\Model\Config::class);
75 $this->_attribute = $this->createMock(\
Magento\Eav\Model\Attribute::class);
76 $this->_storeManager = $this->createMock(\
Magento\Store\Model\StoreManager::class);
77 $this->_storetMock = $this->createMock(\
Magento\Store\Model\Store::class);
78 $this->_scopeConfigMock = $this->createMock(\
Magento\Framework\
App\
Config\ScopeConfigInterface::class);
79 $this->_transportBuilderMock = $this->createMock(\
Magento\Framework\Mail\Template\TransportBuilder::class);
80 $this->_transportMock = $this->createMock(\
Magento\Framework\Mail\TransportInterface::class);
81 $this->attributeFactoryMock = $this->createPartialMock(
85 $this->attributeCustomerMock = $this->createMock(\
Magento\
Customer\Model\Attribute::class);
86 $this->resourceMock = $this->createPartialMock(
91 $this->dataObjectProcessor = $this->createPartialMock(
92 \
Magento\Framework\Reflection\DataObjectProcessor::class,
93 [
'buildOutputDataArray']
96 $this->resourceMock->expects($this->any())
97 ->method(
'getIdFieldName')
98 ->will($this->returnValue(
'id'));
99 $this->registryMock = $this->createPartialMock(\
Magento\Framework\Registry::class, [
'registry']);
100 $this->_encryptor = $this->createMock(\
Magento\Framework\Encryption\EncryptorInterface::class);
101 $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
102 $this->accountConfirmation = $this->createMock(AccountConfirmation::class);
103 $this->_model =
$helper->getObject(
106 'storeManager' => $this->_storeManager,
107 'config' => $this->_config,
108 'transportBuilder' => $this->_transportBuilderMock,
109 'scopeConfig' => $this->_scopeConfigMock,
110 'encryptor' => $this->_encryptor,
111 'attributeFactory' => $this->attributeFactoryMock,
112 'registry' => $this->registryMock,
113 'resource' => $this->resourceMock,
114 'dataObjectProcessor' => $this->dataObjectProcessor,
115 'accountConfirmation' => $this->accountConfirmation
122 $this->_encryptor->expects(
130 $this->returnValue(
'hash')
132 $this->assertEquals(
'hash', $this->_model->hashPassword(
'password',
'salt'));
141 $this->_model->sendNewAccountEmail(
'test');
146 $store = $this->createMock(\
Magento\Store\Model\Store::class);
149 ->method(
'getStoreIds')
150 ->will($this->returnValue([1, 2, 3, 4]));
151 $this->_storeManager->expects($this->once())
152 ->method(
'getWebsite')
154 ->will($this->returnValue(
$website));
155 $this->_storeManager->expects($this->once())
158 ->will($this->returnValue(
$store));
160 $this->_config->expects($this->exactly(3))
161 ->method(
'getAttribute')
162 ->will($this->returnValue($this->_attribute));
164 $this->_attribute->expects($this->exactly(3))
165 ->method(
'getIsVisible')
166 ->will($this->returnValue(
true));
169 'setTemplateIdentifier',
170 'setTemplateOptions',
176 $this->_transportBuilderMock->expects($this->once())
178 ->will($this->returnSelf());
180 $transportMock = $this->createMock(\
Magento\Framework\Mail\TransportInterface::class);
181 $transportMock->expects($this->once())
182 ->method(
'sendMessage')
183 ->will($this->returnSelf());
184 $this->_transportBuilderMock->expects($this->once())
185 ->method(
'getTransport')
186 ->will($this->returnValue($transportMock));
188 $this->_model->setData([
192 'firstname' =>
'FirstName',
193 'lastname' =>
'LastName',
194 'middlename' =>
'MiddleName',
195 'prefix' =>
'Name Prefix',
197 $this->_model->sendNewAccountEmail(
'registered');
207 $this->_model->setLockExpires($lockExpires);
208 $this->assertEquals($expectedResult, $this->_model->isCustomerLocked());
217 [
'lockExpirationDate' => date(
"F j, Y", strtotime(
'-1 days')),
'expectedResult' =>
false],
218 [
'lockExpirationDate' => date(
"F j, Y", strtotime(
'+1 days')),
'expectedResult' =>
true]
232 $isConfirmationRequired,
238 $this->_model->setData(
'website_id',
$websiteId);
241 $this->accountConfirmation->expects($this->once())
242 ->method(
'isConfirmationRequired')
244 ->willReturn($isConfirmationRequired);
246 $this->assertEquals($expected, $this->_model->isConfirmationRequired());
255 [
null,
null,
false,
false],
257 [1,
null,
true,
true],
263 $customerDataAttributes = [
264 'attribute' =>
'attribute',
266 'test33' =>
'test33',
272 'getCustomAttributes',
278 \
Magento\Framework\Api\AttributeValue::class,
285 $this->dataObjectProcessor->expects($this->once())
286 ->method(
'buildOutputDataArray')
289 )->willReturn($customerDataAttributes);
292 ->method(
'getAttributeCode')
293 ->willReturn(
'test33');
297 ->willReturn(
'test33');
300 ->method(
'getCustomAttributes')
305 foreach ($customerDataAttributes as $key =>
$value) {
306 $expectedResult[strtolower(trim(preg_replace(
'/([A-Z]|[0-9]+)/',
"_$1", $key),
'_'))] =
$value;
310 $expectedResult[
'attribute_set_id'] =
313 $this->assertEquals($this->_model->getData(), $expectedResult);
testSendNewAccountEmailWithoutStoreId()
testSendNewAccountEmailException()
testIsCustomerLocked($lockExpires, $expectedResult)
dataProviderIsConfirmationRequired()
isCustomerLockedDataProvider()
testIsConfirmationRequired( $customerId, $websiteId, $isConfirmationRequired, $expected)