ShowTest.php 1.6 KB

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