1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Swatches\Controller\Adminhtml\Iframe;
/**
* @magentoAppArea adminhtml
*/
class ShowTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/**
* Check Swatch Acl Access
*/
public function testAclAccess()
{
/** @var $acl \Magento\Framework\Acl */
$acl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Acl\Builder::class)
->getAcl();
$acl->allow(null, \Magento\Swatches\Controller\Adminhtml\Iframe\Show::ADMIN_RESOURCE);
$this->dispatch('backend/swatches/iframe/show/');
$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
$this->assertNotContains('Sorry, you need permissions to view this content.', $this->getResponse()->getBody());
}
/**
* Check Swatch Acl Access Denied
*/
public function testAclAccessDenied()
{
/** @var $acl \Magento\Framework\Acl */
$acl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Acl\Builder::class)
->getAcl();
$acl->deny(null, \Magento\Swatches\Controller\Adminhtml\Iframe\Show::ADMIN_RESOURCE);
$this->dispatch('backend/swatches/iframe/show/');
$this->assertEquals(403, $this->getResponse()->getHttpResponseCode());
$this->assertContains('Sorry, you need permissions to view this content.', $this->getResponse()->getBody());
}
}