ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\User\Block\Role\Grid;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class UserTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\User\Block\Role\Grid\User
|
||||
*/
|
||||
protected $_block;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\View\LayoutInterface::class
|
||||
);
|
||||
$this->_block = $layout->createBlock(\Magento\User\Block\Role\Grid\User::class);
|
||||
}
|
||||
|
||||
public function testPreparedCollection()
|
||||
{
|
||||
$this->_block->toHtml();
|
||||
$this->assertInstanceOf(
|
||||
\Magento\User\Model\ResourceModel\Role\User\Collection::class,
|
||||
$this->_block->getCollection()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\User\Block\Role\Tab;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class EditTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\User\Block\Role\Tab\Edit
|
||||
*/
|
||||
protected $_block;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$roleAdmin = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(\Magento\Authorization\Model\Role::class);
|
||||
$roleAdmin->load(\Magento\TestFramework\Bootstrap::ADMIN_ROLE_NAME, 'role_name');
|
||||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\App\RequestInterface::class
|
||||
)->setParam(
|
||||
'rid',
|
||||
$roleAdmin->getId()
|
||||
);
|
||||
|
||||
$this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\User\Block\Role\Tab\Edit::class
|
||||
);
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$this->assertNotEmpty($this->_block->getSelectedResources());
|
||||
$this->assertContains('Magento_Backend::all', $this->_block->getSelectedResources());
|
||||
}
|
||||
|
||||
public function testGetTree()
|
||||
{
|
||||
$encodedTree = $this->_block->getTree();
|
||||
$this->assertNotEmpty($encodedTree);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\User\Block\User\Edit\Tab;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class MainTest extends \Magento\TestFramework\TestCase\AbstractBackendController
|
||||
{
|
||||
/**
|
||||
* @var \Magento\User\Block\User\Edit\Tab\Main
|
||||
*/
|
||||
protected $_block;
|
||||
|
||||
/**
|
||||
* @var \Magento\User\Model\User
|
||||
*/
|
||||
protected $_user;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
/** @var $objectManager \Magento\TestFramework\ObjectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
$this->_block = $objectManager->create(\Magento\User\Block\User\Edit\Tab\Main::class);
|
||||
$this->_block->setArea('adminhtml');
|
||||
$this->_block->setNameInLayout('test');
|
||||
$this->_user = $objectManager->create(\Magento\User\Model\User::class);
|
||||
|
||||
$objectManager->get(\Magento\Framework\Registry::class)->register('permissions_user', $this->_user);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->_block = null;
|
||||
$this->_user = null;
|
||||
/** @var $objectManager \Magento\TestFramework\ObjectManager */
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$objectManager->get(\Magento\Framework\Registry::class)->unregister('permissions_user');
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testToHtmlPasswordFieldsExistingEntry()
|
||||
{
|
||||
$this->_user->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME);
|
||||
$actualHtml = $this->_block->toHtml();
|
||||
$this->assertEquals(
|
||||
1,
|
||||
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
|
||||
'//input[contains(@class,"required-entry") and @type="password"]',
|
||||
$actualHtml
|
||||
),
|
||||
'There should be 1 required password entry: current user password.'
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
|
||||
'//input[contains(@class,"validate-admin-password") and @type="password" and @name="password"]',
|
||||
$actualHtml
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
|
||||
'//input[contains(@class,"validate-cpassword") and @type="password" and ' .
|
||||
'@name="password_confirmation"]',
|
||||
$actualHtml
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
|
||||
'//input[contains(@class,"validate-current-password") and @type="password" and @name="'
|
||||
. Main::CURRENT_USER_PASSWORD_FIELD . '"]',
|
||||
$actualHtml
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testToHtmlPasswordFieldsNewEntry()
|
||||
{
|
||||
$actualHtml = $this->_block->toHtml();
|
||||
$this->assertEquals(
|
||||
1,
|
||||
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
|
||||
'//input[contains(@class,"validate-admin-password") and contains(@class,"required-entry") and '
|
||||
. '@type="password" and @name="password"]',
|
||||
$actualHtml
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
1,
|
||||
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
|
||||
'//input[contains(@class,"validate-cpassword") and contains(@class,"required-entry") and '
|
||||
. '@type="password" and @name="password_confirmation"]',
|
||||
$actualHtml
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user