/** @test */
 public function renderCellReturnsRenderedCell()
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('val1', 'field1');
     $row->createAndAddCell('val2', 'field2');
     $row->createAndAddCell('val3', 'field3');
     // see ConfigurationBuilderMock for column definition
     $columnConfig = new Tx_PtExtlist_Domain_Configuration_Columns_ColumnConfig($this->configurationBuilderMock, array('columnIdentifier' => 'column1', 'fieldIdentifier' => 'field1'));
     $cellContent = $this->cellRenderer->renderCell($columnConfig, $row, 0, 0);
     $this->assertEquals('val1', $cellContent->getValue());
 }
Esempio n. 2
0
 /** @test */
 public function renderListReturnsRenderedListForGivenConfiguration()
 {
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('val1', 'field1');
     $row->createAndAddCell('val2', 'field2');
     $row->createAndAddCell('val3', 'field3');
     $row->createAndAddCell('val4', 'field4');
     $listData->addRow($row);
     $renderedList = $this->renderer->renderList($listData);
     $this->assertTrue(is_a($renderedList, 'Tx_PtExtlist_Domain_Model_List_ListData'));
     $this->assertEquals((string) $renderedList->getItemByIndex(0)->getCell('column1'), 'val1');
     $this->assertEquals((string) $renderedList->getItemByIndex(0)->getCell('column4'), 'val4');
 }
 protected function builddataBackendMock()
 {
     $this->testListData = new Tx_PtExtlist_Domain_Model_List_ListData();
     foreach ($this->testData as $data) {
         $row = new Tx_PtExtlist_Domain_Model_List_Row();
         $row->createAndAddCell($data / 10, 'field1');
         $row->createAndAddCell($data, 'field2');
         $row->createAndAddCell($data * 10, 'field3');
         $this->testListData->addRow($row);
     }
     $this->dataBackendMock = $this->getMock('Tx_PtExtlist_Domain_DataBackend_MySqlDataBackend_MySqlDataBackend', array('getListData', 'getAggregatesByConfigCollection'), array(), '', false);
     $this->dataBackendMock->expects($this->any())->method('getListData')->will($this->returnValue($this->testListData));
     $this->dataBackendMock->expects($this->any())->method('getAggregatesByConfigCollection')->will($this->returnValue(array('avgField2' => 5)));
 }
Esempio n. 4
0
 /** @test */
 public function renderRowRendersRowForGivenConfiguration()
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('val1', 'field1');
     $row->createAndAddCell('val2', 'field2');
     $row->createAndAddCell('val3', 'field3');
     $row->createAndAddCell('val4', 'field4');
     $cellRenderer = $this->getMock('Tx_PtExtlist_Domain_Renderer_Default_CellRenderer', array(), array(), '', false);
     $cellRenderer->expects($this->any())->method('renderCell')->will($this->returnValue(new Tx_PtExtlist_Domain_Model_List_Cell('test')));
     $rowRenderer = $this->getRowRenderer();
     $rowRenderer->injectCellRenderer($cellRenderer);
     $renderedRow = $rowRenderer->renderRow($row, 1);
     foreach ($renderedRow as $cell) {
         /* @var $cell Tx_PtExtlist_Domain_Model_List_Cell */
         $this->assertEquals($cell->getValue(), 'test');
     }
 }
 /**
  * Returns list data structure for given domain objects.
  * Uses configuration currently set in mapper.
  *
  * @param mixed $domainObjects
  * @return Tx_PtExtlist_Domain_Model_List_ListData List data generated for given mapping configuration
  */
 public function getMappedListData($domainObjects)
 {
     Tx_PtExtbase_Assertions_Assert::isNotNull($this->fieldConfigurationCollection, array('message' => 'No mapper configuration has been set for domain object mapper! 1281635601'));
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     foreach ($domainObjects as $domainObject) {
         $listDataRow = new Tx_PtExtlist_Domain_Model_List_Row();
         foreach ($this->fieldConfigurationCollection as $fieldConfiguration) {
             /* @var $fieldConfiguration Tx_PtExtlist_Domain_Configuration_Data_Fields_FieldConfig */
             $property = $this->getPropertyNameByFieldConfig($fieldConfiguration);
             if ($property == '__object__') {
                 $value = $domainObject;
             } else {
                 $value = $this->getObjectPropertyValueByProperty($domainObject, $property);
             }
             $listDataRow->createAndAddCell($value, $fieldConfiguration->getIdentifier());
         }
         $listData->addRow($listDataRow);
     }
     return $listData;
 }
Esempio n. 6
0
 /**
  * @test
  */
 public function getAsArray()
 {
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('testContent1', 'col1');
     $row->createAndAddCell('testContent2', 'col2');
     $row->addSpecialValue('key', 'value');
     $actual = $row->getAsArray();
     $this->assertEquals($this->dataArray, $actual);
 }
Esempio n. 7
0
 protected function createTemplateVariableContainer()
 {
     $templateVariableContainer = new \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer();
     $header = new Tx_PtExtlist_Domain_Model_List_Row();
     $header->createAndAddCell('header1Value', 'col1');
     $header->createAndAddCell('header2Value', 'col2');
     $header->createAndAddCell('header3Value', 'col3');
     $row = new Tx_PtExtlist_Domain_Model_List_Row();
     $row->createAndAddCell('col1Value', 'col1');
     $row->createAndAddCell('col2Value', 'col2');
     $row->createAndAddCell('col3Value', 'col3');
     $listData = new Tx_PtExtlist_Domain_Model_List_ListData();
     $listData->addRow($row);
     $templateVariableContainer->add('listCaptions', $header);
     $templateVariableContainer->add('listData', $listData);
     return $templateVariableContainer;
 }
 /**
  * Build the aggregate data by configuration
  * 
  * @return Tx_PtExtlist_Domain_Model_List_Row
  */
 protected function buildAggregateDataRow()
 {
     $dataRow = new Tx_PtExtlist_Domain_Model_List_Row();
     $aggregateDataConfigCollection = $this->configurationBuilder->buildAggregateDataConfig();
     $aggregatesForPage = $this->getAggregatesForPage($aggregateDataConfigCollection->extractCollectionByScope('page'));
     $aggregatesForQuery = $this->getAggregatesForQuery($aggregateDataConfigCollection->extractCollectionByScope('query'));
     \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($aggregatesForQuery, $aggregatesForPage);
     foreach ($aggregatesForQuery as $key => $value) {
         $dataRow->createAndAddCell($value, $key);
     }
     return $dataRow;
 }
Esempio n. 9
0
 /**
  * Maps a single row of a list data structure with given configuration.
  *
  * @param array $row   Row of raw list data array
  * @return Tx_PtExtlist_Domain_Model_List_Row  Mapped row
  */
 protected function mapRowWithConfiguration(array &$row)
 {
     $mappedRow = new Tx_PtExtlist_Domain_Model_List_Row();
     foreach ($this->fieldConfigurationCollection as $mapping) {
         /* @var $mapping Tx_PtExtlist_Domain_Configuration_Data_Fields_FieldConfig */
         $mappedCellValue = $this->getMappedCellValue($mapping, $row);
         $mappedRow->createAndAddCell($mappedCellValue, $mapping->getIdentifier());
     }
     unset($row);
     return $mappedRow;
 }
 protected function buildTestDataBackend()
 {
     $this->testListData = new Tx_PtExtlist_Domain_Model_List_ListData();
     foreach ($this->testData as $data) {
         $row = new Tx_PtExtlist_Domain_Model_List_Row();
         $row->createAndAddCell($data / 10, 'field1');
         $row->createAndAddCell($data, 'field2');
         $row->createAndAddCell($data * 10, 'field3');
         $this->testListData->addRow($row);
     }
     $this->testDataBackend = $this->getMock('Tx_PtExtlist_Domain_DataBackend_MySqlDataBackend_MySqlDataBackend', array('getListData'), array(), '', FALSE);
     $this->testDataBackend->expects($this->any())->method('getListData')->will($this->returnValue($this->testListData));
 }