Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
AccountManagementTest Class Reference
Inheritance diagram for AccountManagementTest:

Public Member Functions

 testLogin ()
 
 testLoginWrongPassword ()
 
 testLoginWrongUsername ()
 
 testChangePassword ()
 
 testChangePasswordWrongPassword ()
 
 testChangePasswordWrongUser ()
 
 testValidateResetPasswordLinkToken ()
 
 testValidateResetPasswordLinkTokenExpired ()
 
 testValidateResetPasswordLinkTokenInvalid ()
 
 testValidateResetPasswordLinkTokenWrongUser ()
 
 testResetPasswordTokenSecondTime ()
 
 testValidateResetPasswordLinkTokenNull ()
 
 testValidateResetPasswordLinkTokenWithoutId ()
 
 testValidateResetPasswordLinkTokenAmbiguous ()
 
 testSendPasswordResetLink ()
 
 testSendPasswordResetLinkDefaultWebsite ()
 
 testSendPasswordResetLinkBadEmailOrWebsite ()
 
 testSendPasswordResetLinkBadEmailDefaultWebsite ()
 
 testResetPassword ()
 
 testResetPasswordTokenExpired ()
 
 testResetPasswordTokenInvalid ()
 
 testResetPasswordTokenWrongUser ()
 
 testResetPasswordTokenInvalidUserEmail ()
 
 testResetPasswordWithoutEmail ()
 
 testResetPasswordAmbiguousToken ()
 
 testResendConfirmation ()
 
 testResendConfirmationBadWebsiteId ()
 
 testResendConfirmationNoEmail ()
 
 testResendConfirmationNotNeeded ()
 
 testCreateCustomerException ()
 
 testCreateNonexistingCustomer ()
 
 testCreateNewCustomer ()
 
 testCreateNewCustomerFromClone ()
 
 testIsEmailAvailable ()
 
 testIsEmailAvailableNoWebsiteSpecified ()
 
 testIsEmailAvailableNoWebsiteSpecifiedNonExistent ()
 
 testIsEmailAvailableNonExistentEmail ()
 
 testGetDefaultBillingAddress ()
 
 testGetDefaultAddressesForNonExistentAddress ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $dataObjectHelper
 

Detailed Description

Integration test for service layer \Magento\Customer\Model\AccountManagementTest

@SuppressWarnings(PHPMD.TooManyMethods) @SuppressWarnings(PHPMD.ExcessivePublicCount) @SuppressWarnings(PHPMD.CouplingBetweenObjects) @magentoAppArea frontend

Definition at line 27 of file AccountManagementTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 59 of file AccountManagementTest.php.

60  {
61  $this->objectManager = Bootstrap::getObjectManager();
62  $this->accountManagement = $this->objectManager
63  ->create(\Magento\Customer\Api\AccountManagementInterface::class);
64  $this->customerRepository = $this->objectManager
65  ->create(\Magento\Customer\Api\CustomerRepositoryInterface::class);
66  $this->addressRepository =
67  $this->objectManager->create(\Magento\Customer\Api\AddressRepositoryInterface::class);
68 
69  $this->addressFactory = $this->objectManager->create(\Magento\Customer\Api\Data\AddressInterfaceFactory::class);
70  $this->customerFactory = $this->objectManager->create(
71  \Magento\Customer\Api\Data\CustomerInterfaceFactory::class
72  );
73  $this->dataObjectHelper = $this->objectManager->create(\Magento\Framework\Api\DataObjectHelper::class);
74 
75  $regionFactory = $this->objectManager->create(\Magento\Customer\Api\Data\RegionInterfaceFactory::class);
76  $address = $this->addressFactory->create();
77  $address->setId('1')
78  ->setCountryId('US')
79  ->setCustomerId('1')
80  ->setPostcode('75477')
81  ->setRegion(
82  $regionFactory->create()->setRegionCode('AL')->setRegion('Alabama')->setRegionId(1)
83  )
84  ->setRegionId(1)
85  ->setCompany('CompanyName')
86  ->setStreet(['Green str, 67'])
87  ->setTelephone('3468676')
88  ->setCity('CityM')
89  ->setFirstname('John')
90  ->setLastname('Smith')
91  ->setIsDefaultShipping(true)
92  ->setIsDefaultBilling(true);
93 
94  $address2 = $this->addressFactory->create();
95  $address2->setId('2')
96  ->setCountryId('US')
97  ->setCustomerId('1')
98  ->setPostcode('47676')
99  ->setRegion(
100  $regionFactory->create()->setRegionCode('AL')->setRegion('Alabama')->setRegionId(1)
101  )
102  ->setRegionId(1)
103  ->setCompany('Company')
104  ->setStreet(['Black str, 48'])
105  ->setCity('CityX')
106  ->setTelephone('3234676')
107  ->setFirstname('John')
108  ->setLastname('Smith');
109 
110  $this->_expectedAddresses = [$address, $address2];
111 
112  $this->dataProcessor = $this->objectManager
113  ->create(\Magento\Framework\Reflection\DataObjectProcessor::class);
114 
115  $this->extensibleDataObjectConverter = $this->objectManager
116  ->create(\Magento\Framework\Api\ExtensibleDataObjectConverter::class);
117  }
$address
Definition: customer.php:38

◆ testChangePassword()

testChangePassword ( )

@magentoAppArea frontend @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 171 of file AccountManagementTest.php.

172  {
173  $this->accountManagement->changePassword('[email protected]', 'password', 'new_Password123');
174 
175  $this->accountManagement->authenticate('[email protected]', 'new_Password123');
176  }

◆ testChangePasswordWrongPassword()

testChangePasswordWrongPassword ( )

@magentoDataFixture Magento/Customer/_files/customer.php

@expectedException \Magento\Framework\Exception\InvalidEmailOrPasswordException @expectedExceptionMessage The password doesn't match this account. Verify the password and try again.

Definition at line 184 of file AccountManagementTest.php.

185  {
186  $this->accountManagement->changePassword('[email protected]', 'wrongPassword', 'new_Password123');
187  }

◆ testChangePasswordWrongUser()

testChangePasswordWrongUser ( )

@expectedException \Magento\Framework\Exception\InvalidEmailOrPasswordException @expectedExceptionMessage Invalid login or password.

Definition at line 193 of file AccountManagementTest.php.

194  {
195  $this->accountManagement->changePassword('[email protected]', '_Password123', 'new_Password123');
196  }

◆ testCreateCustomerException()

testCreateCustomerException ( )

@magentoDbIsolation enabled

Definition at line 619 of file AccountManagementTest.php.

620  {
621  $customerEntity = $this->customerFactory->create();
622 
623  try {
624  $this->accountManagement->createAccount($customerEntity);
625  $this->fail('Expected exception not thrown');
626  } catch (InputException $ie) {
627  $this->assertEquals('The customer email is missing. Enter and try again.', $ie->getMessage());
628  }
629  }

◆ testCreateNewCustomer()

testCreateNewCustomer ( )

@magentoDbIsolation enabled

Definition at line 784 of file AccountManagementTest.php.

785  {
787  $storeId = 1;
788  $firstname = 'Tester';
789  $lastname = 'McTest';
790  $groupId = 1;
791 
792  $newCustomerEntity = $this->customerFactory->create()
793  ->setStoreId($storeId)
794  ->setEmail($email)
795  ->setFirstname($firstname)
796  ->setLastname($lastname)
797  ->setGroupId($groupId);
798  $savedCustomer = $this->accountManagement->createAccount($newCustomerEntity, '_aPassword1');
799  $this->assertNotNull($savedCustomer->getId());
800  $this->assertEquals($email, $savedCustomer->getEmail());
801  $this->assertEquals($storeId, $savedCustomer->getStoreId());
802  $this->assertEquals($firstname, $savedCustomer->getFirstname());
803  $this->assertEquals($lastname, $savedCustomer->getLastname());
804  $this->assertEquals($groupId, $savedCustomer->getGroupId());
805  $this->assertTrue(!$savedCustomer->getSuffix());
806  }
$email
Definition: details.phtml:13

◆ testCreateNewCustomerFromClone()

testCreateNewCustomerFromClone ( )

@magentoAppArea frontend @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 851 of file AccountManagementTest.php.

852  {
854  $firstName = 'Firstsave';
855  $lastname = 'Lastsave';
856 
857  $existingCustId = 1;
858  $existingCustomer = $this->customerRepository->getById($existingCustId);
859  $customerEntity = $this->customerFactory->create();
860  $this->dataObjectHelper->mergeDataObjects(
861  \Magento\Customer\Api\Data\CustomerInterface::class,
862  $customerEntity,
863  $existingCustomer
864  );
865  $customerEntity->setEmail($email)
866  ->setFirstname($firstName)
867  ->setLastname($lastname)
868  ->setId(null);
869 
870  $customer = $this->accountManagement->createAccount($customerEntity, '_aPassword1');
871  $this->assertNotEmpty($customer->getId());
872  $this->assertEquals($email, $customer->getEmail());
873  $this->assertEquals($firstName, $customer->getFirstname());
874  $this->assertEquals($lastname, $customer->getLastname());
875  $this->accountManagement->authenticate(
876  $customer->getEmail(),
877  '_aPassword1',
878  true
879  );
880  }
$customer
Definition: customers.php:11
$email
Definition: details.phtml:13

◆ testCreateNonexistingCustomer()

testCreateNonexistingCustomer ( )

@magentoAppArea frontend @magentoDataFixture Magento/Customer/_files/customer.php @magentoDbIsolation enabled

Definition at line 636 of file AccountManagementTest.php.

637  {
638  $existingCustId = 1;
639  $existingCustomer = $this->customerRepository->getById($existingCustId);
640 
642  $firstName = 'Firstsave';
643  $lastName = 'Lastsave';
644  $customerData = array_merge(
645  $existingCustomer->__toArray(),
646  [
647  'email' => $email,
648  'firstname' => $firstName,
649  'lastname' => $lastName,
650  'id' => null
651  ]
652  );
653  $customerEntity = $this->customerFactory->create();
654  $this->dataObjectHelper->populateWithArray(
655  $customerEntity,
657  \Magento\Customer\Api\Data\CustomerInterface::class
658  );
659 
660  $customerAfter = $this->accountManagement->createAccount($customerEntity, '_aPassword1');
661  $this->assertGreaterThan(0, $customerAfter->getId());
662  $this->assertEquals($email, $customerAfter->getEmail());
663  $this->assertEquals($firstName, $customerAfter->getFirstname());
664  $this->assertEquals($lastName, $customerAfter->getLastname());
665  $this->accountManagement->authenticate(
666  $customerAfter->getEmail(),
667  '_aPassword1'
668  );
669  $attributesBefore = $this->extensibleDataObjectConverter->toFlatArray(
670  $existingCustomer,
671  [],
672  \Magento\Customer\Api\Data\CustomerInterface::class
673  );
674  $attributesAfter = $this->extensibleDataObjectConverter->toFlatArray(
675  $customerAfter,
676  [],
677  \Magento\Customer\Api\Data\CustomerInterface::class
678  );
679  // ignore 'updated_at'
680  unset($attributesBefore['updated_at']);
681  unset($attributesAfter['updated_at']);
682  $inBeforeOnly = array_diff_assoc($attributesBefore, $attributesAfter);
683  $inAfterOnly = array_diff_assoc($attributesAfter, $attributesBefore);
684  $expectedInBefore = [
685  'email',
686  'firstname',
687  'id',
688  'lastname',
689  ];
690  sort($expectedInBefore);
691  $actualInBeforeOnly = array_keys($inBeforeOnly);
692  sort($actualInBeforeOnly);
693  $this->assertEquals($expectedInBefore, $actualInBeforeOnly);
694  $expectedInAfter = [
695  'created_in',
696  'email',
697  'firstname',
698  'id',
699  'lastname',
700  ];
701  $actualInAfterOnly = array_keys($inAfterOnly);
702  foreach ($expectedInAfter as $item) {
703  $this->assertContains($item, $actualInAfterOnly);
704  }
705  }
$customerData
$email
Definition: details.phtml:13

◆ testGetDefaultAddressesForNonExistentAddress()

testGetDefaultAddressesForNonExistentAddress ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 999 of file AccountManagementTest.php.

1000  {
1001  $customerId = 1;
1002  $this->assertNull($this->accountManagement->getDefaultBillingAddress($customerId));
1003  $this->assertNull($this->accountManagement->getDefaultShippingAddress($customerId));
1004  }

◆ testGetDefaultBillingAddress()

testGetDefaultBillingAddress ( )

@magentoDataFixture Magento/Customer/_files/customer.php @magentoDataFixture Magento/Customer/_files/customer_address.php @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php

Definition at line 916 of file AccountManagementTest.php.

917  {
918  $customerId = 1;
919  $address = $this->accountManagement->getDefaultBillingAddress($customerId);
920 
921  $expected = $this->dataProcessor->buildOutputDataArray(
922  $this->_expectedAddresses[0],
923  \Magento\Customer\Api\Data\AddressInterface::class
924  );
925  $result = $this->dataProcessor->buildOutputDataArray(
926  $address,
927  \Magento\Customer\Api\Data\AddressInterface::class
928  );
929  /*
930  * TODO : Data builder / populateWithArray currently does not detect
931  * array type and returns street as string instead of array. Need to fix this.
932  */
933  unset($expected[AddressInterface::STREET]);
935  $this->assertEquals($expected, $result);
936  }
$address
Definition: customer.php:38

◆ testIsEmailAvailable()

testIsEmailAvailable ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 885 of file AccountManagementTest.php.

886  {
887  $this->assertFalse($this->accountManagement->isEmailAvailable('[email protected]', 1));
888  }

◆ testIsEmailAvailableNonExistentEmail()

testIsEmailAvailableNonExistentEmail ( )

Definition at line 906 of file AccountManagementTest.php.

907  {
908  $this->assertTrue($this->accountManagement->isEmailAvailable('[email protected]', 1));
909  }

◆ testIsEmailAvailableNoWebsiteSpecified()

testIsEmailAvailableNoWebsiteSpecified ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 893 of file AccountManagementTest.php.

894  {
895  $this->assertFalse($this->accountManagement->isEmailAvailable('[email protected]'));
896  }

◆ testIsEmailAvailableNoWebsiteSpecifiedNonExistent()

testIsEmailAvailableNoWebsiteSpecifiedNonExistent ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 901 of file AccountManagementTest.php.

902  {
903  $this->assertTrue($this->accountManagement->isEmailAvailable('[email protected]'));
904  }

◆ testLogin()

testLogin ( )

@magentoAppArea frontend @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 138 of file AccountManagementTest.php.

139  {
140  // Customer email and password are pulled from the fixture customer.php
141  $customer = $this->accountManagement->authenticate('[email protected]', 'password');
142 
143  $this->assertSame('[email protected]', $customer->getEmail());
144  }
$customer
Definition: customers.php:11

◆ testLoginWrongPassword()

testLoginWrongPassword ( )

@magentoDataFixture Magento/Customer/_files/customer.php

@expectedException \Magento\Framework\Exception\InvalidEmailOrPasswordException

Definition at line 151 of file AccountManagementTest.php.

152  {
153  // Customer email and password are pulled from the fixture customer.php
154  $this->accountManagement->authenticate('[email protected]', 'wrongPassword');
155  }

◆ testLoginWrongUsername()

testLoginWrongUsername ( )

@expectedException \Magento\Framework\Exception\InvalidEmailOrPasswordException @expectedExceptionMessage Invalid login or password.

Definition at line 161 of file AccountManagementTest.php.

162  {
163  // Customer email and password are pulled from the fixture customer.php
164  $this->accountManagement->authenticate('non_existing_user', '_Password123');
165  }

◆ testResendConfirmation()

testResendConfirmation ( )

@magentoAppArea frontend @magentoAppIsolation enabled @magentoDataFixture Magento/Customer/_files/inactive_customer.php

Definition at line 568 of file AccountManagementTest.php.

569  {
570  $this->accountManagement->resendConfirmation('[email protected]', 1);
571  //TODO assert
572  }

◆ testResendConfirmationBadWebsiteId()

testResendConfirmationBadWebsiteId ( )

@magentoAppArea frontend @magentoAppIsolation enabled @magentoDataFixture Magento/Customer/_files/inactive_customer.php

Definition at line 579 of file AccountManagementTest.php.

580  {
581  try {
582  $this->accountManagement->resendConfirmation('[email protected]', 'notAWebsiteId');
583  } catch (NoSuchEntityException $nsee) {
584  $this->assertEquals(
585  'No such entity with email = [email protected], websiteId = notAWebsiteId',
586  $nsee->getMessage()
587  );
588  }
589  }

◆ testResendConfirmationNoEmail()

testResendConfirmationNoEmail ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 594 of file AccountManagementTest.php.

595  {
596  try {
597  $this->accountManagement->resendConfirmation('[email protected]', 1);
598  $this->fail('Expected exception not thrown.');
599  } catch (NoSuchEntityException $nsee) {
600  $this->assertEquals(
601  'No such entity with email = [email protected], websiteId = 1',
602  $nsee->getMessage()
603  );
604  }
605  }

◆ testResendConfirmationNotNeeded()

testResendConfirmationNotNeeded ( )

@magentoDataFixture Magento/Customer/_files/customer.php @expectedException \Magento\Framework\Exception\State\InvalidTransitionException

Definition at line 611 of file AccountManagementTest.php.

612  {
613  $this->accountManagement->resendConfirmation('[email protected]', 1);
614  }

◆ testResetPassword()

testResetPassword ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 453 of file AccountManagementTest.php.

454  {
455  $resetToken = 'lsdj579slkj5987slkj595lkj';
456  $password = 'new_Password123';
457 
458  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s');
459  $this->assertTrue($this->accountManagement->resetPassword('[email protected]', $resetToken, $password));
460  }

◆ testResetPasswordAmbiguousToken()

testResetPasswordAmbiguousToken ( )

@magentoDataFixture Magento/Customer/_files/two_customers.php @expectedException \Magento\Framework\Exception\State\ExpiredException

Definition at line 554 of file AccountManagementTest.php.

555  {
556  $resetToken = 'lsdj579slkj5987slkj595lkj';
557  $password = 'new_Password123';
558  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s', 1);
559  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s', 2);
560  $this->accountManagement->resetPassword(null, $resetToken, $password);
561  }

◆ testResetPasswordTokenExpired()

testResetPasswordTokenExpired ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 465 of file AccountManagementTest.php.

466  {
467  $resetToken = 'lsdj579slkj5987slkj595lkj';
468  $password = 'new_Password123';
469 
470  $this->setResetPasswordData($resetToken, '1970-01-01');
471  try {
472  $this->accountManagement->resetPassword('[email protected]', $resetToken, $password);
473  $this->fail('Expected exception not thrown.');
474  } catch (ExpiredException $e) {
475  $this->assertEquals('The password token is expired. Reset and try again.', $e->getMessage());
476  }
477  }

◆ testResetPasswordTokenInvalid()

testResetPasswordTokenInvalid ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 483 of file AccountManagementTest.php.

484  {
485  $resetToken = 'lsdj579slkj5987slkj595lkj';
486  $invalidToken = 0;
487  $password = 'new_Password123';
488 
489  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s');
490  try {
491  $this->accountManagement->resetPassword('[email protected]', $invalidToken, $password);
492  $this->fail('Expected exception not thrown.');
493  } catch (InputException $ie) {
494  $this->assertEquals('"%fieldName" is required. Enter and try again.', $ie->getRawMessage());
495  $this->assertEquals('"resetPasswordLinkToken" is required. Enter and try again.', $ie->getMessage());
496  $this->assertEquals('"resetPasswordLinkToken" is required. Enter and try again.', $ie->getLogMessage());
497  $this->assertEmpty($ie->getErrors());
498  }
499  }

◆ testResetPasswordTokenInvalidUserEmail()

testResetPasswordTokenInvalidUserEmail ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 523 of file AccountManagementTest.php.

524  {
525  $resetToken = 'lsdj579slkj5987slkj595lkj';
526  $password = 'new_Password123';
527 
528  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s');
529 
530  try {
531  $this->accountManagement->resetPassword('invalid', $resetToken, $password);
532  $this->fail('Expected exception not thrown.');
533  } catch (NoSuchEntityException $e) {
534  $this->assertEquals('No such entity with email = invalid, websiteId = 1', $e->getMessage());
535  }
536  }

◆ testResetPasswordTokenSecondTime()

testResetPasswordTokenSecondTime ( )

Test for resetPassword() method when reset for the second time

@magentoDataFixture Magento/Customer/_files/customer.php @expectedException \Magento\Framework\Exception\State\InputMismatchException

Definition at line 333 of file AccountManagementTest.php.

334  {
335  $resetToken = 'lsdj579slkj5987slkj595lkj';
336  $password = 'new_Password123';
338  $this->setResetPasswordData($resetToken, 'Y-m-d H:i');
339  $this->assertTrue($this->accountManagement->resetPassword($email, $resetToken, $password));
340  $this->accountManagement->resetPassword($email, $resetToken, $password);
341  }
$email
Definition: details.phtml:13

◆ testResetPasswordTokenWrongUser()

testResetPasswordTokenWrongUser ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 504 of file AccountManagementTest.php.

505  {
506  $resetToken = 'lsdj579slkj5987slkj595lkj';
507  $password = 'new_Password123';
508  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s');
509  try {
510  $this->accountManagement->resetPassword('[email protected]', $resetToken, $password);
511  $this->fail('Expected exception not thrown.');
512  } catch (NoSuchEntityException $nsee) {
513  $this->assertEquals(
514  'No such entity with email = [email protected], websiteId = 1',
515  $nsee->getMessage()
516  );
517  }
518  }

◆ testResetPasswordWithoutEmail()

testResetPasswordWithoutEmail ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 541 of file AccountManagementTest.php.

542  {
543  $resetToken = 'lsdj579slkj5987slkj595lkj';
544  $password = 'new_Password123';
545  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s');
546  $this->assertTrue(
547  $this->accountManagement->resetPassword(null, $resetToken, $password)
548  );
549  }

◆ testSendPasswordResetLink()

testSendPasswordResetLink ( )

@magentoAppArea frontend @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 387 of file AccountManagementTest.php.

388  {
390 
391  $this->accountManagement->initiatePasswordReset($email, AccountManagement::EMAIL_RESET, 1);
392  }
$email
Definition: details.phtml:13

◆ testSendPasswordResetLinkBadEmailDefaultWebsite()

testSendPasswordResetLinkBadEmailDefaultWebsite ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 434 of file AccountManagementTest.php.

435  {
437 
438  try {
439  $this->accountManagement->initiatePasswordReset(
440  $email,
442  );
443  $this->fail('Expected exception not thrown.');
444  } catch (NoSuchEntityException $nsee) {
445  // App area is frontend, so we expect websiteId of 1.
446  $this->assertEquals('No such entity with email = [email protected], websiteId = 1', $nsee->getMessage());
447  }
448  }
$email
Definition: details.phtml:13

◆ testSendPasswordResetLinkBadEmailOrWebsite()

testSendPasswordResetLinkBadEmailOrWebsite ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 409 of file AccountManagementTest.php.

410  {
412 
413  try {
414  $this->accountManagement->initiatePasswordReset(
415  $email,
417  0
418  );
419  $this->fail('Expected exception not thrown.');
420  } catch (NoSuchEntityException $e) {
421  $expectedParams = [
422  'fieldName' => 'email',
423  'fieldValue' => $email,
424  'field2Name' => 'websiteId',
425  'field2Value' => 0,
426  ];
427  $this->assertEquals($expectedParams, $e->getParameters());
428  }
429  }
$email
Definition: details.phtml:13

◆ testSendPasswordResetLinkDefaultWebsite()

testSendPasswordResetLinkDefaultWebsite ( )

@magentoAppArea frontend @magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 398 of file AccountManagementTest.php.

399  {
401 
402  $this->accountManagement->initiatePasswordReset($email, AccountManagement::EMAIL_RESET);
403  }
$email
Definition: details.phtml:13

◆ testValidateResetPasswordLinkToken()

testValidateResetPasswordLinkToken ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 275 of file AccountManagementTest.php.

276  {
277  $this->setResetPasswordData('token', 'Y-m-d H:i:s');
278  $this->accountManagement->validateResetPasswordLinkToken(1, 'token');
279  }

◆ testValidateResetPasswordLinkTokenAmbiguous()

testValidateResetPasswordLinkTokenAmbiguous ( )

@magentoDataFixture Magento/Customer/_files/two_customers.php @expectedException \Magento\Framework\Exception\State\ExpiredException

Definition at line 375 of file AccountManagementTest.php.

376  {
377  $token = 'randomStr123';
378  $this->setResetPasswordData($token, 'Y-m-d H:i:s', 1);
379  $this->setResetPasswordData($token, 'Y-m-d H:i:s', 2);
380  $this->accountManagement->validateResetPasswordLinkToken(null, $token);
381  }

◆ testValidateResetPasswordLinkTokenExpired()

testValidateResetPasswordLinkTokenExpired ( )

@magentoDataFixture Magento/Customer/_files/customer.php @expectedException \Magento\Framework\Exception\State\ExpiredException

Definition at line 285 of file AccountManagementTest.php.

286  {
287  $resetToken = 'lsdj579slkj5987slkj595lkj';
288  $this->setResetPasswordData($resetToken, '1970-01-01');
289  $this->accountManagement->validateResetPasswordLinkToken(1, $resetToken);
290  }

◆ testValidateResetPasswordLinkTokenInvalid()

testValidateResetPasswordLinkTokenInvalid ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 295 of file AccountManagementTest.php.

296  {
297  $resetToken = 'lsdj579slkj5987slkj595lkj';
298  $invalidToken = 0;
299  $this->setResetPasswordData($resetToken, 'Y-m-d H:i:s');
300  try {
301  $this->accountManagement->validateResetPasswordLinkToken(1, $invalidToken);
302  $this->fail('Expected exception not thrown.');
303  } catch (InputException $ie) {
304  $this->assertEquals('"%fieldName" is required. Enter and try again.', $ie->getRawMessage());
305  $this->assertEquals('"resetPasswordLinkToken" is required. Enter and try again.', $ie->getMessage());
306  $this->assertEquals('"resetPasswordLinkToken" is required. Enter and try again.', $ie->getLogMessage());
307  $this->assertEmpty($ie->getErrors());
308  }
309  }

◆ testValidateResetPasswordLinkTokenNull()

testValidateResetPasswordLinkTokenNull ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 347 of file AccountManagementTest.php.

348  {
349  try {
350  $this->accountManagement->validateResetPasswordLinkToken(1, null);
351  $this->fail('Expected exception not thrown.');
352  } catch (InputException $ie) {
353  $this->assertEquals('"%fieldName" is required. Enter and try again.', $ie->getRawMessage());
354  $this->assertEquals('"resetPasswordLinkToken" is required. Enter and try again.', $ie->getMessage());
355  $this->assertEquals('"resetPasswordLinkToken" is required. Enter and try again.', $ie->getLogMessage());
356  $this->assertEmpty($ie->getErrors());
357  }
358  }

◆ testValidateResetPasswordLinkTokenWithoutId()

testValidateResetPasswordLinkTokenWithoutId ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 363 of file AccountManagementTest.php.

364  {
365  $token = 'randomStr123';
366  $this->setResetPasswordData($token, 'Y-m-d H:i:s');
367  $this->assertTrue(
368  $this->accountManagement->validateResetPasswordLinkToken(null, $token)
369  );
370  }

◆ testValidateResetPasswordLinkTokenWrongUser()

testValidateResetPasswordLinkTokenWrongUser ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 315 of file AccountManagementTest.php.

316  {
317  $resetToken = 'lsdj579slkj5987slkj595lkj';
318 
319  try {
320  $this->accountManagement->validateResetPasswordLinkToken(4200, $resetToken);
321  $this->fail('Expected exception not thrown.');
322  } catch (NoSuchEntityException $nsee) {
323  $this->assertEquals('No such entity with customerId = 4200', $nsee->getMessage());
324  }
325  }

Field Documentation

◆ $dataObjectHelper

$dataObjectHelper
protected

Definition at line 57 of file AccountManagementTest.php.


The documentation for this class was generated from the following file: