/** @test */ public function renderCaptionsReturnsLocalizedLabels() { $methods = array('getLabel', 'getColumnIdentifier'); $returnMethods['getLabel'] = 'LLL:EXT:pt_extlist/Tests/Domain/Renderer/locallang.xml:test'; $returnMethods['getColoumnIdentifier'] = 'test'; $headerColumn = $this->getConfiguredMock('Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn', $methods, $returnMethods); $columnConfigMock = $this->getAccessibleMock('Tx_PtExtlist_Domain_Configuration_Columns_ColumnConfig', array('isAccessable'), array(), '', FALSE); $columnConfigMock->expects($this->any())->method('isAccessable')->will($this->returnValue(true)); $headerColumn->injectColumnConfig($columnConfigMock); // we need to give a list to the renderer $listHeader = new Tx_PtExtlist_Domain_Model_List_Header_ListHeader($this->configurationBuilderMock->getListIdentifier()); $listHeader->addHeaderColumn($headerColumn, 'test'); $captions = $this->captionRenderer->renderCaptions($listHeader); $this->assertEquals('TEST', $captions->getItemByIndex(0)->getValue()); }
/** * @param Tx_PtExtlist_Domain_Model_List_Header_ListHeader $headers */ public function render() { $columns = $this->arguments['columns']; $options = array(); $selectedOptions = array(); foreach ($columns as $columnIdentifier => $column) { /** @var $column Tx_PtExtlist_Domain_Model_List_Header_HeaderColumn */ if (!($this->columnSelectorConfig->getHideDefaultVisibleInSelector() && $column->getColumnConfig()->getIsVisible())) { $options[$columnIdentifier] = $this->captionRenderer->renderColumnLabel($column); } if ($column->getIsVisible()) { $selectedOptions[] = $columnIdentifier; } } // This hack is needed to be backwards compatible to Fluid 1.3.0 where arguments was an object if (is_a($this->arguments, 'Tx_Fluid_Core_ViewHelper_Arguments')) { $arg = (array) $this->arguments; $arg['multiple'] = 1; $arg['name'] = $this->arguments['name']; $arg['options'] = $options; $arg['value'] = $selectedOptions; $this->arguments = new \TYPO3\CMS\Fluid\Core\ViewHelper\Arguments($arg); } else { $this->arguments['options'] = $options; $this->arguments['value'] = $selectedOptions; } return parent::render(); }