public function testGetColumnUnknownColumn() { $column = new VcsStats_Report_Element_Table_Column('Dummy', 'dummy'); $table = new VcsStats_Report_Element_Table(); $table->addColumn($column); $this->setExpectedException('OutOfBoundsException'); $this->assertSame($column, $table->getColumn('unknown')); }
/** * Generate table output * * @param VcsStats_Table $table Table * @return void */ public function renderTable(VcsStats_Report_Element_Table $table) { $result = ''; $output = new ezcConsoleOutput(); $output->formats->title->style = array('bold'); $alignments = array('center' => ezcConsoleTable::ALIGN_CENTER, 'left' => ezcConsoleTable::ALIGN_LEFT, 'right' => ezcConsoleTable::ALIGN_RIGHT); $consoleTable = new ezcConsoleTable($output, 78); // Display header $consoleTable[0]->align = ezcConsoleTable::ALIGN_CENTER; foreach ($table->getColumns() as $column) { $consoleTable[0][]->content = $column->getTitle(); } // Display values foreach ($table->getRows() as $i => $row) { $j = 0; foreach ($row as $code => $value) { $alignment = $table->getColumn($code)->getAlignment(); $consoleTable[$i + 1][$j]->align = $alignments[$alignment]; $consoleTable[$i + 1][$j]->content = $value; $j++; } } ob_start(); $output->outputLine(); $output->outputLine($table->getTitle(), 'title'); $consoleTable->outputTable(); $output->outputLine(); $output->outputLine(); $result .= ob_get_clean(); echo $result; }