Skip to content

Commit

Permalink
Merge branch 'main' into cache-enabled-modules
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel authored Oct 30, 2024
2 parents 05c60f8 + 9fc0d23 commit c7dcbc1
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getFormKey()
}

/**
* Check whether or not the module output is enabled
* Check whether the module output is enabled
*
* Because many module blocks belong to Adminhtml module,
* the feature "Disable module output" doesn't cover Admin area
Expand All @@ -53,7 +53,8 @@ public function isOutputEnabled($moduleName = null)
if ($moduleName === null) {
$moduleName = $this->getModuleName();
}
return !Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $moduleName);

return Mage::helper('core')->isModuleOutputEnabled($moduleName);
}

/**
Expand Down
93 changes: 93 additions & 0 deletions tests/unit/Mage/Adminhtml/Block/TemplateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

/**
* OpenMage
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available at https://opensource.org/license/osl-3-0-php
*
* @category OpenMage
* @package OpenMage_Tests
* @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org)
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

declare(strict_types=1);

namespace OpenMage\Tests\Unit\Mage\Adminhtml\Block;

use Generator;
use Mage;
use Mage_Adminhtml_Block_Template;
use PHPUnit\Framework\TestCase;

class TemplateTest extends TestCase
{
public Mage_Adminhtml_Block_Template $subject;

public function setUp(): void
{
Mage::app();
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
$this->subject = new Mage_Adminhtml_Block_Template();
}

/**
* @see Mage_Core_Model_Session::getFormKey()
* @group Mage_Adminhtml
* @group Mage_Adminhtml_Block
* @group runInSeparateProcess
* @runInSeparateProcess
*/
public function testGetFormKey(): void
{
$this->assertIsString($this->subject->getFormKey());
}

/**
* @covers Mage_Adminhtml_Block_Template::isOutputEnabled()
* @dataProvider provideIsOutputEnabled
* @group Mage_Adminhtml
* @group Mage_Adminhtml_Block
*/
public function testIsOutputEnabled(bool $expectedResult, ?string $moduleName): void
{
$this->assertSame($expectedResult, $this->subject->isOutputEnabled($moduleName));
}

public function provideIsOutputEnabled(): Generator
{
yield 'null' => [
true,
null, #Mage_Adminhtml
];
yield 'Mage_Core' => [
true,
'Mage_Core',
];
yield 'Not_Exist' => [
false,
'Not_Exist',
];
}

/**
* @group Mage_Adminhtml
* @group Mage_Adminhtml_Block
*/
public function testGetModuleName(): void
{
$this->assertSame('Mage_Adminhtml', $this->subject->getModuleName());
}

/**
* @see Mage_Core_Model_Input_Filter_MaliciousCode::filter()
* @group Mage_Adminhtml
* @group Mage_Adminhtml_Block
*/
public function testMaliciousCodeFilter(): void
{
$this->assertIsString($this->subject->maliciousCodeFilter(''));
}
}

0 comments on commit c7dcbc1

Please sign in to comment.