Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class Mage_Adminhtml_Block_Widget_Grid_Column extends Mage_Adminhtml_Block_Widge
protected $_type;
protected $_cssClass = null;

/**
* @param Mage_Adminhtml_Block_Widget_Grid $grid
* @return $this
*/
public function setGrid($grid)
{
$this->_grid = $grid;
Expand All @@ -46,6 +50,9 @@ public function setGrid($grid)
return $this;
}

/**
* @return Mage_Adminhtml_Block_Widget_Grid
*/
public function getGrid()
{
return $this->_grid;
Expand Down Expand Up @@ -160,6 +167,7 @@ public function getRowField(Varien_Object $row)
*/
$frameCallback = $this->getFrameCallback();
if (is_array($frameCallback)) {
// phpcs:ignore Ecg.Security.ForbiddenFunction.Found
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, false);
}

Expand Down Expand Up @@ -188,6 +196,7 @@ public function getRowFieldExport(Varien_Object $row)
*/
$frameCallback = $this->getFrameCallback();
if (is_array($frameCallback)) {
// phpcs:ignore Ecg.Security.ForbiddenFunction.Found
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, true);
}

Expand Down Expand Up @@ -222,15 +231,22 @@ protected function &_applyDecorators($value, $decorators)
return $value;
}

/**
* @param string $renderer
* @return $this
*/
public function setRenderer($renderer)
{
$this->_renderer = $renderer;
return $this;
}

/**
* @return string
*/
protected function _getRendererByType()
{
$type = strtolower((string)$this->getType());
$type = strtolower($this->getType());
$renderers = $this->getGrid()->getColumnRenderers();

if (is_array($renderers) && isset($renderers[$type])) {
Expand Down Expand Up @@ -317,15 +333,22 @@ public function getRenderer()
return $this->_renderer;
}

/**
* @param string $filterClass
* @return void
*/
public function setFilter($filterClass)
{
$this->_filter = $this->getLayout()->createBlock($filterClass)
->setColumn($this);
}

/**
* @return string
*/
protected function _getFilterByType()
{
$type = strtolower((string)$this->getType());
$type = strtolower($this->getType());
$filters = $this->getGrid()->getColumnFilters();
if (is_array($filters) && isset($filters[$type])) {
return $filters[$type];
Expand Down Expand Up @@ -424,4 +447,9 @@ public function getExportHeader()
}
return $this->getHeader();
}

public function getType(): string
{
return (string) $this->_getData('type');
}
}
44 changes: 44 additions & 0 deletions tests/unit/Mage/Adminhtml/Block/Widget/Grid/ColumnTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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\Widget\Grid;

use Mage_Adminhtml_Block_Widget_Grid_Column;
use PHPUnit\Framework\TestCase;

class ColumnTest extends TestCase
{
public Mage_Adminhtml_Block_Widget_Grid_Column $subject;

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

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

$this->subject->setType('text');
$this->assertSame('text', $this->subject->getType());
}
}
13 changes: 13 additions & 0 deletions tests/unit/Mage/Core/Model/ConfigTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<?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\Core\Model;
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/Mage/Core/Model/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ public function setUp(): void
$this->subject = Mage::getModel('core/url');
}

/**
* @group Mage_Core
* @group Mage_Core_Model
*/
public function testEscape(): void
{
$this->assertSame('%22%27%3E%3C', $this->subject->escape('"\'><'));
}

/**
* @group Mage_Core
* @group Mage_Core_Model
Expand Down