/** * Function to get html for Foreign key form * * @param array $columns columns * @param array $existrel_foreign db, table, column * @param string $db current database * @param string $tbl_storage_engine table storage engine * @param array $options_array options array * * @return string */ function PMA_getHtmlForForeignKeyForm($columns, $existrel_foreign, $db, $tbl_storage_engine, $options_array) { $html_output = '<fieldset>' . '<legend>' . __('Foreign key constraints') . '</legend>' . '<table id="foreign_keys" class="relationalTable">'; $html_output .= '<tr><th>' . __('Actions') . '</th>'; $html_output .= '<th>' . __('Constraint properties') . '</th>' . '<th>' . __('Column') . PMA_Util::showHint(__('Only columns with index will be displayed. You can define an' . ' index below.')) . '</th>'; $html_output .= '<th colspan="3">' . __('Foreign key constraint') . ' (' . $tbl_storage_engine . ')'; $html_output .= '</th></tr>'; $odd_row = true; $i = 0; foreach ($existrel_foreign as $key => $one_key) { $html_output .= PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i++, $options_array, $tbl_storage_engine, $db); $odd_row = !$odd_row; } $html_output .= PMA_getHtmlForForeignKeyRow(array(), $odd_row, $columns, $i++, $options_array, $tbl_storage_engine, $db); $html_output .= '<tr>' . '<td colspan="5"><a class="formelement clearfloat' . ' add_foreign_key" href="">' . __('+ Add constraint') . '</td>'; $html_output .= '</tr>'; $html_output .= '</table>' . '</fieldset>'; return $html_output; }
/** * Tests for PMA_getHtmlForCommonForm() method. * * @return void * @test */ public function testPMAGetHtmlForCommonForm() { $db = "pma_db"; $table = "pma_table"; $columns = array(array("Field" => "Field1")); $cfgRelation = array('displaywork' => true, 'relwork' => true, 'displaywork' => true); $tbl_storage_engine = "InnoDB"; $existrel = array(); $existrel_foreign = array(); $options_array = array(); $save_row = array(); foreach ($columns as $row) { $save_row[] = $row; } $html = PMA_getHtmlForCommonForm($db, $table, $columns, $cfgRelation, $tbl_storage_engine, $existrel, $existrel_foreign, $options_array); //case 1: PMA_getHtmlForInternalRelationForm $this->assertContains(PMA_getHtmlForInternalRelationForm($columns, $tbl_storage_engine, $existrel, $db), $html); //case 2: PMA_getHtmlForForeignKeyForm $this->assertContains(PMA_getHtmlForForeignKeyForm($columns, $existrel_foreign, $db, $tbl_storage_engine, $options_array), $html); $this->assertContains(PMA_URL_getHiddenInputs($db, $table), $html); $this->assertContains(__('Relations'), $html); $this->assertContains(__('Column'), $html); $this->assertContains(__('Internal relation'), $html); $this->assertContains(__('Choose column to display:'), $html); //case 3: PMA_getHtmlForInternalRelationRow $row = PMA_getHtmlForInternalRelationRow($save_row, 0, true, $existrel, $db); $this->assertContains($row, $html); //case 4: PMA_getHtmlForForeignKeyRow $row = PMA_getHtmlForForeignKeyRow(array(), true, $columns, 0, $options_array, $tbl_storage_engine, $db); $this->assertContains($row, $html); //case 5: PMA_getHtmlForDisplayFieldInfos $this->assertContains(PMA_getHtmlForDisplayFieldInfos($db, $table, $save_row), $html); //case 6: PMA_getHtmlForCommonFormFooter $this->assertContains(PMA_getHtmlForCommonFormFooter(), $html); }