@magentoAppArea adminhtml
Definition at line 14 of file UserTest.php.
◆ beforeSavePasswordInsecureDataProvider()
beforeSavePasswordInsecureDataProvider |
( |
| ) |
|
Definition at line 403 of file UserTest.php.
405 return [
'alpha chars only' => [
'aaaaaaaa'],
'digits only' => [
'1234567']];
◆ roleDataFixture()
static roleDataFixture |
( |
| ) |
|
|
static |
Definition at line 107 of file UserTest.php.
110 \
Magento\Authorization\Model\Role::class
112 self::$_newRole->setName(
'admin_role')->setRoleType(
'G')->setPid(
'1');
113 self::$_newRole->save();
static getObjectManager()
◆ setUp()
Definition at line 36 of file UserTest.php.
42 \
Magento\Framework\Stdlib\DateTime::class
static getObjectManager()
◆ testAuthenticate()
@magentoAppIsolation enabled @magentoAdminConfigFixture admin/captcha/enable 0 @magentoAdminConfigFixture admin/security/use_case_sensitive_login 1
Definition at line 208 of file UserTest.php.
210 $this->assertFalse($this->_model->authenticate(
'User', \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD));
212 $this->_model->authenticate(
213 \
Magento\TestFramework\Bootstrap::ADMIN_NAME,
214 \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
◆ testAuthenticateCaseInsensitive()
testAuthenticateCaseInsensitive |
( |
| ) |
|
@magentoAppIsolation enabled @magentoAdminConfigFixture admin/captcha/enable 0 @magentoConfigFixture current_store admin/security/use_case_sensitive_login 0
Definition at line 224 of file UserTest.php.
226 $this->assertTrue($this->_model->authenticate(
'user', \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD));
228 $this->_model->authenticate(
229 \
Magento\TestFramework\Bootstrap::ADMIN_NAME,
230 \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
◆ testAuthenticateInactiveUser()
testAuthenticateInactiveUser |
( |
| ) |
|
@expectedException \Magento\Framework\Exception\LocalizedException @expectedException \Magento\Framework\Exception\AuthenticationException @magentoDbIsolation enabled
Definition at line 240 of file UserTest.php.
242 $this->_model->load(1);
243 $this->_model->setIsActive(0)->save();
244 $this->_model->authenticate(
245 \
Magento\TestFramework\Bootstrap::ADMIN_NAME,
246 \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
◆ testAuthenticateUserWithoutRole()
testAuthenticateUserWithoutRole |
( |
| ) |
|
@expectedException \Magento\Framework\Exception\AuthenticationException @magentoDbIsolation enabled
Definition at line 254 of file UserTest.php.
256 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
257 $roles = $this->_model->getRoles();
258 $this->_model->setRoleId(reset($roles))->deleteFromRole();
259 $this->_model->authenticate(
260 \
Magento\TestFramework\Bootstrap::ADMIN_NAME,
261 \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
◆ testBeforeSavePasswordInsecure()
testBeforeSavePasswordInsecure |
( |
|
$password | ) |
|
@dataProvider beforeSavePasswordInsecureDataProvider @expectedException \Magento\Framework\Exception\LocalizedException @expectedExceptionMessage Your password must include both numeric and alphabetic characters. @magentoDbIsolation enabled
- Parameters
-
Definition at line 397 of file UserTest.php.
399 $this->_model->setPassword($password);
400 $this->_model->save();
◆ testBeforeSavePasswordsDoNotMatch()
testBeforeSavePasswordsDoNotMatch |
( |
| ) |
|
@expectedException \Magento\Framework\Exception\LocalizedException @expectedExceptionMessage Your password confirmation must match your password. @magentoDbIsolation enabled
Definition at line 372 of file UserTest.php.
374 $this->_model->setPassword(
'password2');
375 $this->_model->setPasswordConfirmation(
'password1');
376 $this->_model->save();
◆ testBeforeSavePasswordTooShort()
testBeforeSavePasswordTooShort |
( |
| ) |
|
@expectedException \Magento\Framework\Exception\LocalizedException @expectedExceptionMessage Your password must include both numeric and alphabetic characters. @magentoDbIsolation enabled
Definition at line 384 of file UserTest.php.
386 $this->_model->setPassword(
'123456');
387 $this->_model->save();
◆ testBeforeSaveRequiredFieldsValidation()
testBeforeSaveRequiredFieldsValidation |
( |
| ) |
|
@expectedException \Magento\Framework\Exception\LocalizedException @expectedExceptionMessage "User Name" is required. Enter and try again. @expectedExceptionMessage "First Name" is required. Enter and try again. @expectedExceptionMessage "Last Name" is required. Enter and try again. @expectedExceptionMessage Please enter a valid email. @expectedExceptionMessage "Password" is required. Enter and try again. @magentoDbIsolation enabled
Definition at line 326 of file UserTest.php.
328 $this->_model->setSomething(
'some_value');
330 $this->_model->save();
◆ testBeforeSaveUserIdentityViolation()
testBeforeSaveUserIdentityViolation |
( |
| ) |
|
@expectedException \Magento\Framework\Exception\LocalizedException @expectedExceptionMessage A user with the same user name or email already exists. @magentoDbIsolation enabled
Definition at line 413 of file UserTest.php.
415 $this->_model->setUsername(
'user');
416 $this->_model->save();
◆ testBeforeSaveValidationSuccess()
testBeforeSaveValidationSuccess |
( |
| ) |
|
@magentoDbIsolation enabled
Definition at line 422 of file UserTest.php.
424 $this->_model->setUsername(
434 )->setPasswordConfirmation(
437 $this->_model->save();
◆ testChangeResetPasswordLinkToken()
testChangeResetPasswordLinkToken |
( |
| ) |
|
@magentoDbIsolation enabled
Definition at line 443 of file UserTest.php.
445 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
446 $this->_model->changeResetPasswordLinkToken(
'test');
447 $date = $this->_model->getRpTokenCreatedAt();
448 $this->assertNotNull($date);
449 $this->_model->save();
450 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
451 $this->assertEquals(
'test', $this->_model->getRpToken());
452 $this->assertEquals(strtotime($date), strtotime($this->_model->getRpTokenCreatedAt()));
◆ testCreatedOnUpdate()
@magentoDataFixture Magento/User/_files/dummy_user.php
Definition at line 73 of file UserTest.php.
75 $this->_model->loadByUsername(
'user_created_date');
76 $this->assertEquals(
'2010-01-06 00:00:00', $this->_model->getCreated());
78 $this->_model->getResource()->recordLogin($this->_model);
79 $this->_model->reload();
80 $this->assertEquals(
'2010-01-06 00:00:00', $this->_model->getCreated());
◆ testCRUD()
@magentoDbIsolation enabled
Definition at line 52 of file UserTest.php.
54 $this->_model->setFirstname(
61 \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
66 $crud = new \Magento\TestFramework\Entity($this->_model, [
'firstname' =>
'_New_name_']);
◆ testDeleteFromRole()
@magentoDbIsolation enabled
Definition at line 160 of file UserTest.php.
162 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
163 $roles = $this->_model->getRoles();
164 $this->_model->setRoleId(reset($roles))->deleteFromRole();
165 $role = $this->_model->getRole();
166 $this->assertNull($role->getId());
◆ testGetCollection()
Definition at line 179 of file UserTest.php.
181 $this->assertInstanceOf(
183 $this->_model->getCollection()
◆ testGetName()
Definition at line 187 of file UserTest.php.
191 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
192 $this->assertEquals(
"$firstname $lastname", $this->_model->getName());
193 $this->assertEquals(
"$firstname///$lastname", $this->_model->getName(
'
◆ testGetRole()
@magentoDataFixture roleDataFixture
Definition at line 146 of file UserTest.php.
148 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
149 $role = $this->_model->getRole();
150 $this->assertInstanceOf(\
Magento\Authorization\Model\Role::class, $role);
151 $this->assertEquals(\
Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, $this->_model->getRole()->getRoleName());
152 $this->_model->setRoleId(self::$_newRole->getId())->save();
153 $role = $this->_model->getRole();
154 $this->assertEquals(self::$_newRole->getId(), $role->getId());
◆ testGetRoles()
@magentoDataFixture roleDataFixture
Definition at line 131 of file UserTest.php.
133 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
134 $roles = $this->_model->getRoles();
135 $this->assertEquals(1, count($roles));
136 $this->assertEquals(\
Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, $this->_model->getRole()->getRoleName());
137 $this->_model->setRoleId(self::$_newRole->getId())->save();
138 $roles = $this->_model->getRoles();
139 $this->assertEquals(1, count($roles));
140 $this->assertEquals(self::$_newRole->getId(), $roles[0]);
◆ testGetSetHasAvailableResources()
testGetSetHasAvailableResources |
( |
| ) |
|
Definition at line 475 of file UserTest.php.
477 $this->_model->setHasAvailableResources(
true);
478 $this->assertTrue($this->_model->hasAvailableResources());
480 $this->_model->setHasAvailableResources(
false);
481 $this->assertFalse($this->_model->hasAvailableResources());
◆ testGetUninitializedAclRole()
testGetUninitializedAclRole |
( |
| ) |
|
Definition at line 196 of file UserTest.php.
199 $newuser->setUserId(10);
200 $this->assertNull($newuser->getAclRole(),
"User role was not initialized and is expected to be empty.");
static getObjectManager()
◆ testHasAssigned2Role()
@magentoDbIsolation enabled
Definition at line 306 of file UserTest.php.
308 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
309 $role = $this->_model->hasAssigned2Role($this->_model);
310 $this->assertEquals(1, count($role));
311 $this->assertArrayHasKey(
'role_id', $role[0]);
312 $roles = $this->_model->getRoles();
313 $this->_model->setRoleId(reset($roles))->deleteFromRole();
314 $this->assertEmpty($this->_model->hasAssigned2Role($this->_model));
◆ testIsResetPasswordLinkTokenExpired()
testIsResetPasswordLinkTokenExpired |
( |
| ) |
|
@magentoDbIsolation enabled @magentoAppIsolation enabled @magentoConfigFixture default/admin/emails/password_reset_link_expiration_period 2
Definition at line 460 of file UserTest.php.
462 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
463 $this->assertTrue($this->_model->isResetPasswordLinkTokenExpired());
464 $this->_model->changeResetPasswordLinkToken(
'test');
465 $this->_model->save();
466 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
467 $this->assertFalse($this->_model->isResetPasswordLinkTokenExpired());
468 $this->_model->setRpTokenCreatedAt($this->_dateTime->formatDate(
time() - 60 * 60 * 2 + 2));
469 $this->assertFalse($this->_model->isResetPasswordLinkTokenExpired());
471 $this->_model->setRpTokenCreatedAt($this->_dateTime->formatDate(
time() - 60 * 60 * 2 - 1));
472 $this->assertTrue($this->_model->isResetPasswordLinkTokenExpired());
◆ testLoadByUsername()
Ensure that an exception is not thrown, if the user does not exist
Definition at line 86 of file UserTest.php.
88 $this->_model->loadByUsername(
'non_existing_user');
89 $this->assertNull($this->_model->getId(),
'The admin user has an unexpected ID');
90 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
91 $this->assertNotEmpty($this->_model->getId(),
'The admin user should have been loaded');
◆ testLoginsAreLogged()
@magentoDbIsolation enabled @magentoAdminConfigFixture admin/captcha/enable 0
Definition at line 269 of file UserTest.php.
271 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
272 $lognum = $this->_model->getLognum();
274 $beforeLogin =
time();
275 $this->_model->login(
276 \
Magento\TestFramework\Bootstrap::ADMIN_NAME,
277 \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
279 $loginTime = strtotime($this->_model->getLogdate());
281 $this->assertTrue($beforeLogin <= $loginTime && $loginTime <=
time());
282 $this->assertEquals(++$lognum, $this->_model->getLognum());
284 $beforeLogin =
time();
285 $this->_model->login(
286 \
Magento\TestFramework\Bootstrap::ADMIN_NAME,
287 \
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
289 $loginTime = strtotime($this->_model->getLogdate());
290 $this->assertTrue($beforeLogin <= $loginTime && $loginTime <=
time());
291 $this->assertEquals(++$lognum, $this->_model->getLognum());
◆ testPerformIdentityCheck()
testPerformIdentityCheck |
( |
| ) |
|
Here we test if admin identity check executed successfully
@magentoDataFixture Magento/User/_files/user_with_role.php
Definition at line 489 of file UserTest.php.
491 $this->_model->loadByUsername(
'adminUser');
493 $this->_model->performIdentityCheck($passwordString);
◆ testPerformIdentityCheckLockExpires()
testPerformIdentityCheckLockExpires |
( |
| ) |
|
Here we check for a locked user
@magentoDataFixture Magento/User/_files/locked_users.php @expectedException \Magento\Framework\Exception\State\UserLockedException
Definition at line 519 of file UserTest.php.
521 $this->_model->loadByUsername(
'adminUser2');
522 $this->_model->performIdentityCheck(\
Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
524 $this->expectExceptionMessage(
525 'The account sign-in was incorrect or your account is disabled temporarily. ' 526 .
'Please wait and try again later.'
◆ testPerformIdentityCheckWrongPassword()
testPerformIdentityCheckWrongPassword |
( |
| ) |
|
Here we check for a wrong password
@magentoDataFixture Magento/User/_files/user_with_role.php @expectedException \Magento\Framework\Exception\AuthenticationException
Definition at line 502 of file UserTest.php.
504 $this->_model->loadByUsername(
'adminUser');
505 $passwordString =
'wrongPassword';
506 $this->_model->performIdentityCheck($passwordString);
508 $this->expectExceptionMessage(
509 'The password entered for the current user is invalid. Verify the password and try again.'
◆ testReload()
Definition at line 294 of file UserTest.php.
296 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
297 $this->_model->setFirstname(
'NewFirstName');
298 $this->assertEquals(
'NewFirstName', $this->_model->getFirstname());
299 $this->_model->reload();
300 $this->assertEquals(\
Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME, $this->_model->getFirstname());
◆ testRoleUserExists()
Definition at line 169 of file UserTest.php.
171 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
172 $role = $this->_model->getRole();
173 $this->_model->setRoleId($role->getId());
174 $this->assertTrue($this->_model->roleUserExists());
175 $this->_model->setRoleId(100);
176 $this->assertFalse($this->_model->roleUserExists());
◆ testSaveExtra()
@magentoDbIsolation enabled
Definition at line 119 of file UserTest.php.
121 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
122 $this->_model->saveExtra([
'test' =>
'val']);
123 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
124 $extra = $this->serializer->unserialize($this->_model->getExtra());
125 $this->assertEquals(
$extra[
'test'],
'val');
if( $_orders &&count( $_orders))( 'Orders') ?></caption >< thead >< tr >< th scopeforeach( $_orders as $_order)(__( 'Order #')) ?>" class $extra
◆ testUpdateRoleOnSave()
Test that user role is updated after save
@magentoDataFixture roleDataFixture
Definition at line 99 of file UserTest.php.
101 $this->_model->loadByUsername(\
Magento\TestFramework\Bootstrap::ADMIN_NAME);
102 $this->assertEquals(\
Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, $this->_model->getRole()->getRoleName());
103 $this->_model->setRoleId(self::$_newRole->getId())->save();
104 $this->assertEquals(
'admin_role', $this->_model->getRole()->getRoleName());
◆ $_dateTime
◆ $_model
◆ $_newRole
The documentation for this class was generated from the following file:
- vendor/magento/magento2-base/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php