This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,42 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\User\Controller\Adminhtml\Locks;
use Magento\TestFramework\TestCase\AbstractBackendController;
/**
* Testing the list of locked users.
*
* @magentoAppArea adminhtml
*/
class GridTest extends AbstractBackendController
{
/**
* Test index action
*
* @magentoDbIsolation enabled
* @magentoDataFixture Magento/User/_files/locked_users.php
*/
public function testGridAction()
{
$this->dispatch('backend/admin/locks/grid');
$body = $this->getResponse()->getBody();
$this->assertStringContainsString('data-column="username"', $body);
$this->assertStringContainsString('data-column="last_login"', $body);
$this->assertStringContainsString('data-column="last_login"', $body);
$this->assertStringContainsString('data-column="failures_num"', $body);
$this->assertStringContainsString('data-column="lock_expires"', $body);
$this->assertMatchesRegularExpression(
'/<td data-column\="username"\s*class\="[^"]*col-name[^"]*col-username[^"]*"\s*>\s*adminUser1\s*<\/td>/',
$body
);
$this->assertMatchesRegularExpression(
'/<td data-column\="username"\s*class\="[^"]*col-name[^"]*col-username[^"]*"\s*>\s*adminUser2\s*<\/td>/',
$body
);
}
}
@@ -0,0 +1,37 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\User\Controller\Adminhtml\Locks;
/**
* Locked users page test.
*
* @magentoAppArea adminhtml
*/
class IndexTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/**
* Test index action
*
* @magentoDbIsolation enabled
* @magentoDataFixture Magento/User/_files/locked_users.php
*/
public function testIndexAction()
{
$this->dispatch('backend/admin/locks/index');
$body = $this->getResponse()->getBody();
$this->assertStringContainsString('<h1 class="page-title">Locked Users</h1>', $body);
$this->assertMatchesRegularExpression(
'/<td data-column\="username"\s*class\="[^"]*col-name[^"]*col-username[^"]*"\s*>\s*adminUser1\s*<\/td>/',
$body
);
$this->assertMatchesRegularExpression(
'/<td data-column\="username"\s*class\="[^"]*col-name[^"]*col-username\s*"[^"]*>\s*adminUser2\s*<\/td>/',
$body
);
}
}
@@ -0,0 +1,43 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\User\Controller\Adminhtml\Locks;
/**
* Testing unlock controller.
*
* @magentoAppArea adminhtml
*/
class MassUnlockTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/**
* Test index action
*
* @magentoDbIsolation enabled
* @magentoDataFixture Magento/User/_files/locked_users.php
*/
public function testMassUnlockAction()
{
$userIds = [];
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var $model \Magento\User\Model\User */
$model = $objectManager->create(\Magento\User\Model\User::class);
$userIds[] = $model->loadByUsername('adminUser1')->getId();
$userIds[] = $model->loadByUsername('adminUser2')->getId();
$request = $this->getRequest();
$request->setPostValue(
'unlock',
$userIds
);
$this->dispatch('backend/admin/locks/massunlock');
$this->assertSessionMessages(
$this->containsEqual((string)__('Unlocked %1 user(s).', count($userIds))),
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
);
$this->assertRedirect();
}
}