diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php index 34e54f3406b..bf71385667d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php @@ -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; @@ -46,6 +50,9 @@ public function setGrid($grid) return $this; } + /** + * @return Mage_Adminhtml_Block_Widget_Grid + */ public function getGrid() { return $this->_grid; @@ -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); } @@ -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); } @@ -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])) { @@ -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]; @@ -424,4 +447,9 @@ public function getExportHeader() } return $this->getHeader(); } + + public function getType(): string + { + return (string) $this->_getData('type'); + } } diff --git a/tests/unit/Mage/Adminhtml/Block/Widget/Grid/ColumnTest.php b/tests/unit/Mage/Adminhtml/Block/Widget/Grid/ColumnTest.php new file mode 100644 index 00000000000..f5589b383c2 --- /dev/null +++ b/tests/unit/Mage/Adminhtml/Block/Widget/Grid/ColumnTest.php @@ -0,0 +1,44 @@ +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()); + } +} diff --git a/tests/unit/Mage/Core/Model/ConfigTest.php b/tests/unit/Mage/Core/Model/ConfigTest.php index 7e90bd5d27a..c6cfba9530d 100644 --- a/tests/unit/Mage/Core/Model/ConfigTest.php +++ b/tests/unit/Mage/Core/Model/ConfigTest.php @@ -1,5 +1,18 @@ 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