init
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Ui\Controller\Adminhtml\Index\Renderer;
|
||||
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
*/
|
||||
class HandleTest extends \Magento\TestFramework\TestCase\AbstractBackendController
|
||||
{
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*/
|
||||
public function testExecuteWhenUserDoesNotHavePermission()
|
||||
{
|
||||
Bootstrap::getObjectManager()->configure([
|
||||
'preferences' => [
|
||||
AuthorizationInterface::class => \Magento\Ui\Model\AuthorizationMock::class
|
||||
]
|
||||
]);
|
||||
$this->getRequest()->setParam('handle', 'customer_index_index');
|
||||
$this->getRequest()->setParam('namespace', 'customer_listing');
|
||||
$this->getRequest()->setParam('sorting%5Bfield%5D', 'entity_id');
|
||||
$this->getRequest()->setParam('paging%5BpageSize%5D', 20);
|
||||
$this->getRequest()->setParam('isAjax', 1);
|
||||
$this->dispatch('backend/mui/index/render_handle');
|
||||
$output = $this->getResponse()->getBody();
|
||||
$this->assertEmpty($output, 'The acl restriction wasn\'t applied properly');
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Customer/_files/customer.php
|
||||
*/
|
||||
public function testExecuteWhenUserHasPermission()
|
||||
{
|
||||
$this->getRequest()->setParam('handle', 'customer_index_index');
|
||||
$this->getRequest()->setParam('namespace', 'customer_listing');
|
||||
$this->getRequest()->setParam('sorting%5Bfield%5D', 'entity_id');
|
||||
$this->getRequest()->setParam('paging%5BpageSize%5D', 20);
|
||||
$this->getRequest()->setParam('isAjax', 1);
|
||||
$this->dispatch('backend/mui/index/render_handle');
|
||||
$output = $this->getResponse()->getBody();
|
||||
$this->assertNotEmpty($output, 'The acl restriction wasn\'t applied properly');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Ui\Controller\Index;
|
||||
|
||||
use Magento\TestFramework\TestCase\AbstractController;
|
||||
use Laminas\Http\Headers;
|
||||
|
||||
/**
|
||||
* Test component rendering on storefront.
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
class RenderTest extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Test content type being chosen based on context.
|
||||
*/
|
||||
public function testContentType()
|
||||
{
|
||||
$this->getRequest()->setParam('namespace', 'widget_recently_viewed');
|
||||
$this->getRequest()->setHeaders(Headers::fromString('Accept: application/json'));
|
||||
$this->dispatch('mui/index/render');
|
||||
$this->assertNotEmpty($contentType = $this->getResponse()->getHeader('Content-Type'));
|
||||
$this->assertEquals('application/json', $contentType->getFieldValue());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user