/**
  * Tests for PMA_getHtmlForIndexForm() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForIndexForm()
 {
     $fields = array("field_name" => "field_type");
     $index = new PMA_Index();
     $form_params = array('db' => 'db', 'table' => 'table', 'create_index' => 1);
     $add_fields = 3;
     $html = PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields);
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs($form_params), $html);
     //Index name
     $this->assertContains(__('Index name:'), $html);
     $doc_html = PMA_Util::showHint(PMA_Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!')));
     $this->assertContains($doc_html, $html);
     //Index name
     $this->assertContains(__('Index name:'), $html);
     $this->assertContains(PMA_Util::showMySQLDocu('ALTER_TABLE'), $html);
     //generateIndexSelector
     $this->assertContains($index->generateIndexSelector(), $html);
     //items
     $this->assertContains(__('Column'), $html);
     $this->assertContains(__('Size'), $html);
     $this->assertContains(sprintf(__('Add %s column(s) to index'), 1), $html);
     //$field_name & $field_type
     $this->assertContains("field_name", $html);
     $this->assertContains("field_type", $html);
 }
Beispiel #2
0
$index = PMA_prepareFormValues($db, $table);
/**
 * Process the data from the edit/create index form,
 * run the query to build the new index
 * and moves back to "tbl_sql.php"
 */
if (isset($_REQUEST['do_save_data'])) {
    PMA_handleCreateOrEditIndex($db, $table, $index);
}
// end builds the new index
/**
 * Display the form to edit/create an index
 */
require_once 'libraries/tbl_info.inc.php';
$add_fields = PMA_getNumberOfFieldsForForm($index);
$form_params = PMA_getFormParameters($db, $table);
// Get fields and stores their name/type
if (isset($_REQUEST['create_edit_table'])) {
    $fields = json_decode($_REQUEST['columns'], true);
    $index_params = array('Non_unique' => $_REQUEST['index']['Index_type'] == 'UNIQUE' ? '0' : '1');
    $index->set($index_params);
    $add_fields = count($fields);
} else {
    $fields = PMA_getNameAndTypeOfTheColumns($db, $table);
}
$html = PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields);
$response = PMA_Response::getInstance();
$response->addHTML($html);
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('indexes.js');