forked from MahoCommerce/maho
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
Mage_Adminhtml_Block_Template::isOutputEnabled()
for invalid mo…
…dule (#4320) * fix isOutputEnabled * Update tests/unit/Mage/Adminhtml/Block/TemplateTest.php Co-authored-by: Justin Beaty <51970393+justinbeaty@users.noreply.github.com> * fix OpenMage/magento-lts#4320 (comment) * updated tests --------- Co-authored-by: Justin Beaty <51970393+justinbeaty@users.noreply.github.com>
- Loading branch information
1 parent
f2029b9
commit 8418701
Showing
3 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('')); | ||
} | ||
} |