Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-09-05 04:38:07 +02:00
commit 6ed4a3c533
19 changed files with 1814 additions and 1812 deletions

View File

@ -10,6 +10,7 @@ use PhpMyAdmin\Bookmark;
use PhpMyAdmin\Core;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\File;
use PhpMyAdmin\Import;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Response;
use PhpMyAdmin\Sql;
@ -30,12 +31,9 @@ if (isset($_REQUEST['show_as_php'])) {
$GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
}
// Import functions.
require_once 'libraries/import.lib.php';
// If there is a request to 'Simulate DML'.
if (isset($_REQUEST['simulate_dml'])) {
PMA_handleSimulateDMLRequest();
Import::handleSimulateDmlRequest();
exit;
}
@ -147,7 +145,7 @@ if (! empty($sql_query)) {
// If there is a request to ROLLBACK when finished.
if (isset($_REQUEST['rollback_query'])) {
PMA_handleRollbackRequest($import_text);
Import::handleRollbackRequest($import_text);
}
// refresh navigation and main panels
@ -464,12 +462,12 @@ if ($import_file != 'none' && ! $error) {
$import_handle = new File($import_file);
$import_handle->checkUploadedFile();
if ($import_handle->isError()) {
PMA_stopImport($import_handle->getError());
Import::stop($import_handle->getError());
}
$import_handle->setDecompressContent(true);
$import_handle->open();
if ($import_handle->isError()) {
PMA_stopImport($import_handle->getError());
Import::stop($import_handle->getError());
}
} elseif (! $error) {
if (! isset($import_text) || empty($import_text)) {
@ -480,7 +478,7 @@ if ($import_file != 'none' && ! $error) {
'by your PHP configuration. See [doc@faq1-16]FAQ 1.16[/doc].'
)
);
PMA_stopImport($message);
Import::stop($message);
}
}
@ -503,7 +501,7 @@ if (Encoding::isSupported() && isset($charset_of_file)) {
if (! $error && isset($_POST['skip'])) {
$original_skip = $skip = intval($_POST['skip']);
while ($skip > 0 && ! $finished) {
PMA_importGetNextChunk($skip < $read_limit ? $skip : $read_limit);
Import::getNextChunk($skip < $read_limit ? $skip : $read_limit);
// Disable read progressivity, otherwise we eat all memory!
$read_multiply = 1;
$skip -= $read_limit;
@ -529,7 +527,7 @@ if (! $error) {
$message = PhpMyAdmin\Message::error(
__('Could not load import plugins, please check your installation!')
);
PMA_stopImport($message);
Import::stop($message);
} else {
// Do the real import
try {

1696
libraries/classes/Import.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
*/
namespace PhpMyAdmin\Plugins\Import;
use PhpMyAdmin\Import;
use PhpMyAdmin\Message;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
use PhpMyAdmin\Properties\Options\Items\TextPropertyItem;
@ -241,7 +242,7 @@ class ImportCsv extends AbstractImportCsv
$max_cols = 0;
$csv_terminated_len = mb_strlen($csv_terminated);
while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
$data = Import::getNextChunk();
if ($data === false) {
// subtract data we didn't handle yet and stop processing
$GLOBALS['offset'] -= strlen($buffer);
@ -572,7 +573,7 @@ class ImportCsv extends AbstractImportCsv
* @todo maybe we could add original line to verbose
* SQL in comment
*/
PMA_importRunQuery($sql, $sql, $sql_data);
Import::runQuery($sql, $sql, $sql_data);
}
$line++;
@ -625,7 +626,7 @@ class ImportCsv extends AbstractImportCsv
/* Obtain the best-fit MySQL types for each column */
$analyses = array();
$analyses[] = PMA_analyzeTable($tables[0]);
$analyses[] = Import::analyzeTable($tables[0]);
/**
* string $db_name (no backquotes)
@ -648,14 +649,14 @@ class ImportCsv extends AbstractImportCsv
$create = null;
/* Created and execute necessary SQL statements from data */
PMA_buildSQL($db_name, $tables, $analyses, $create, $options, $sql_data);
Import::buildSql($db_name, $tables, $analyses, $create, $options, $sql_data);
unset($tables);
unset($analyses);
}
// Commit any possible data in buffers
PMA_importRunQuery('', '', $sql_data);
Import::runQuery('', '', $sql_data);
if (count($values) != 0 && !$error) {
$message = Message::error(

View File

@ -8,6 +8,7 @@
*/
namespace PhpMyAdmin\Plugins\Import;
use PhpMyAdmin\Import;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\Import\AbstractImportCsv;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@ -169,8 +170,8 @@ class ImportLdi extends AbstractImportCsv
$sql .= ')';
}
PMA_importRunQuery($sql, $sql, $sql_data);
PMA_importRunQuery('', '', $sql_data);
Import::runQuery($sql, $sql, $sql_data);
Import::runQuery('', '', $sql_data);
$finished = true;
}
}

View File

@ -8,6 +8,7 @@
*/
namespace PhpMyAdmin\Plugins\Import;
use PhpMyAdmin\Import;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Properties\Plugins\ImportPluginProperties;
@ -92,7 +93,7 @@ class ImportMediawiki extends ImportPlugin
$cur_table_name = "";
while (!$finished && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
$data = Import::getNextChunk();
if ($data === false) {
// Subtract data we didn't handle yet and stop processing
@ -307,19 +308,19 @@ class ImportMediawiki extends ImportPlugin
// Set generic names for table headers if they don't exist
$this->_setTableHeaders($table[1], $table[2][0]);
// Create the tables array to be used in PMA_buildSQL()
// Create the tables array to be used in Import::buildSql()
$tables = array();
$tables [] = array($table[0], $table[1], $table[2]);
// Obtain the best-fit MySQL types for each column
$analyses = array();
$analyses [] = PMA_analyzeTable($tables[0]);
$analyses [] = Import::analyzeTable($tables[0]);
$this->_executeImportTables($tables, $analyses, $sql_data);
}
// Commit any possible data in buffers
PMA_importRunQuery('', '', $sql_data);
Import::runQuery('', '', $sql_data);
}
/**
@ -360,7 +361,7 @@ class ImportMediawiki extends ImportPlugin
}
/**
* Sets the database name and additional options and calls PMA_buildSQL()
* Sets the database name and additional options and calls Import::buildSql()
* Used in PMA_importDataAllTables() and $this->_importDataOneTable()
*
* @param array &$tables structure:
@ -392,7 +393,7 @@ class ImportMediawiki extends ImportPlugin
$create = null;
// Create and execute necessary SQL statements from data
PMA_buildSQL($db_name, $tables, $analyses, $create, $options, $sql_data);
Import::buildSql($db_name, $tables, $analyses, $create, $options, $sql_data);
unset($tables);
unset($analyses);

View File

@ -10,6 +10,7 @@
*/
namespace PhpMyAdmin\Plugins\Import;
use PhpMyAdmin\Import;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Properties\Plugins\ImportPluginProperties;
@ -108,11 +109,11 @@ class ImportOds extends ImportPlugin
$buffer = "";
/**
* Read in the file via PMA_importGetNextChunk so that
* Read in the file via Import::getNextChunk so that
* it can process compressed files
*/
while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
$data = Import::getNextChunk();
if ($data === false) {
/* subtract data we didn't handle yet and stop processing */
$GLOBALS['offset'] -= strlen($buffer);
@ -235,7 +236,7 @@ class ImportOds extends ImportPlugin
}
} else {
for ($i = 0; $i < $num_null; ++$i) {
$col_names[] = PMA_getColumnAlphaName(
$col_names[] = Import::getColumnAlphaName(
$col_count + 1
);
++$col_count;
@ -245,7 +246,7 @@ class ImportOds extends ImportPlugin
if (!$col_names_in_first_row) {
$tempRow[] = 'NULL';
} else {
$col_names[] = PMA_getColumnAlphaName(
$col_names[] = Import::getColumnAlphaName(
$col_count + 1
);
}
@ -294,7 +295,7 @@ class ImportOds extends ImportPlugin
/* Fill out column names */
for ($i = count($col_names); $i < $max_cols; ++$i) {
$col_names[] = PMA_getColumnAlphaName($i + 1);
$col_names[] = Import::getColumnAlphaName($i + 1);
}
/* Fill out all rows */
@ -329,15 +330,15 @@ class ImportOds extends ImportPlugin
for ($i = 0; $i < $num_tables; ++$i) {
$num_rows = count($rows);
for ($j = 0; $j < $num_rows; ++$j) {
if (strcmp($tables[$i][TBL_NAME], $rows[$j][TBL_NAME])) {
if (strcmp($tables[$i][Import::TBL_NAME], $rows[$j][Import::TBL_NAME])) {
continue;
}
if (!isset($tables[$i][COL_NAMES])) {
$tables[$i][] = $rows[$j][COL_NAMES];
if (!isset($tables[$i][Import::COL_NAMES])) {
$tables[$i][] = $rows[$j][Import::COL_NAMES];
}
$tables[$i][ROWS] = $rows[$j][ROWS];
$tables[$i][Import::ROWS] = $rows[$j][Import::ROWS];
}
}
@ -349,7 +350,7 @@ class ImportOds extends ImportPlugin
$len = count($tables);
for ($i = 0; $i < $len; ++$i) {
$analyses[] = PMA_analyzeTable($tables[$i]);
$analyses[] = Import::analyzeTable($tables[$i]);
}
/**
@ -373,13 +374,13 @@ class ImportOds extends ImportPlugin
$create = null;
/* Created and execute necessary SQL statements from data */
PMA_buildSQL($db_name, $tables, $analyses, $create, $options, $sql_data);
Import::buildSql($db_name, $tables, $analyses, $create, $options, $sql_data);
unset($tables);
unset($analyses);
/* Commit any possible data in buffers */
PMA_importRunQuery('', '', $sql_data);
Import::runQuery('', '', $sql_data);
}
/**

View File

@ -13,6 +13,7 @@ use PhpMyAdmin\Gis\GisMultiLineString;
use PhpMyAdmin\Gis\GisMultiPoint;
use PhpMyAdmin\Gis\GisPoint;
use PhpMyAdmin\Gis\GisPolygon;
use PhpMyAdmin\Import;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Properties\Plugins\ImportPluginProperties;
@ -250,12 +251,12 @@ class ImportShp extends ImportPlugin
// Use data from shape file to chose best-fit MySQL types for each column
$analyses = array();
$analyses[] = PMA_analyzeTable($tables[0]);
$analyses[] = Import::analyzeTable($tables[0]);
$table_no = 0;
$spatial_col = 0;
$analyses[$table_no][TYPES][$spatial_col] = GEOMETRY;
$analyses[$table_no][FORMATTEDSQL][$spatial_col] = true;
$analyses[$table_no][Import::TYPES][$spatial_col] = Import::GEOMETRY;
$analyses[$table_no][Import::FORMATTEDSQL][$spatial_col] = true;
// Set database name to the currently selected one, if applicable
if (strlen($db) > 0) {
@ -268,7 +269,7 @@ class ImportShp extends ImportPlugin
// Created and execute necessary SQL statements from data
$null_param = null;
PMA_buildSQL($db_name, $tables, $analyses, $null_param, $options, $sql_data);
Import::buildSql($db_name, $tables, $analyses, $null_param, $options, $sql_data);
unset($tables);
unset($analyses);
@ -277,7 +278,7 @@ class ImportShp extends ImportPlugin
$error = false;
// Commit any possible data in buffers
PMA_importRunQuery('', '', $sql_data);
Import::runQuery('', '', $sql_data);
}
/**
@ -298,7 +299,7 @@ class ImportShp extends ImportPlugin
if ($GLOBALS['finished']) {
$eof = true;
} else {
$buffer .= PMA_importGetNextChunk();
$buffer .= Import::getNextChunk();
}
}
$result = substr($buffer, 0, $length);

View File

@ -8,6 +8,7 @@
*/
namespace PhpMyAdmin\Plugins\Import;
use PhpMyAdmin\Import;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Properties\Plugins\ImportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -116,7 +117,7 @@ class ImportSql extends ImportPlugin
}
/**
* Will be set in PMA_importGetNextChunk().
* Will be set in Import::getNextChunk().
*
* @global bool $GLOBALS ['finished']
*/
@ -132,7 +133,7 @@ class ImportSql extends ImportPlugin
if (empty($statement)) {
// Importing new data.
$newData = PMA_importGetNextChunk();
$newData = Import::getNextChunk();
// Subtract data we didn't handle yet and stop processing.
if ($newData === false) {
@ -154,19 +155,19 @@ class ImportSql extends ImportPlugin
}
// Executing the query.
PMA_importRunQuery($statement, $statement, $sql_data);
Import::runQuery($statement, $statement, $sql_data);
}
// Extracting remaining statements.
while ((!$error) && (!$timeout_passed) && (!empty($bq->query))) {
$statement = $bq->extract(true);
if (!empty($statement)) {
PMA_importRunQuery($statement, $statement, $sql_data);
Import::runQuery($statement, $statement, $sql_data);
}
}
// Finishing.
PMA_importRunQuery('', '', $sql_data);
Import::runQuery('', '', $sql_data);
}
/**

View File

@ -10,6 +10,7 @@
namespace PhpMyAdmin\Plugins\Import;
use PhpMyAdmin\Import;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\ImportPlugin;
use PhpMyAdmin\Properties\Plugins\ImportPluginProperties;
@ -66,11 +67,11 @@ class ImportXml extends ImportPlugin
$buffer = "";
/**
* Read in the file via PMA_importGetNextChunk so that
* Read in the file via Import::getNextChunk so that
* it can process compressed files
*/
while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
$data = PMA_importGetNextChunk();
$data = Import::getNextChunk();
if ($data === false) {
/* subtract data we didn't handle yet and stop processing */
$GLOBALS['offset'] -= strlen($buffer);
@ -249,7 +250,7 @@ class ImportXml extends ImportPlugin
$isInTables = false;
$num_tables = count($tables);
for ($i = 0; $i < $num_tables; ++$i) {
if (!strcmp($tables[$i][TBL_NAME], (string)$tbl_attr['name'])) {
if (!strcmp($tables[$i][Import::TBL_NAME], (string)$tbl_attr['name'])) {
$isInTables = true;
break;
}
@ -284,12 +285,12 @@ class ImportXml extends ImportPlugin
for ($i = 0; $i < $num_tables; ++$i) {
$num_rows = count($rows);
for ($j = 0; $j < $num_rows; ++$j) {
if (!strcmp($tables[$i][TBL_NAME], $rows[$j][TBL_NAME])) {
if (!isset($tables[$i][COL_NAMES])) {
$tables[$i][] = $rows[$j][COL_NAMES];
if (!strcmp($tables[$i][Import::TBL_NAME], $rows[$j][Import::TBL_NAME])) {
if (!isset($tables[$i][Import::COL_NAMES])) {
$tables[$i][] = $rows[$j][Import::COL_NAMES];
}
$tables[$i][ROWS][] = $rows[$j][ROWS];
$tables[$i][Import::ROWS][] = $rows[$j][Import::ROWS];
}
}
}
@ -301,7 +302,7 @@ class ImportXml extends ImportPlugin
$len = count($tables);
for ($i = 0; $i < $len; ++$i) {
$analyses[] = PMA_analyzeTable($tables[$i]);
$analyses[] = Import::analyzeTable($tables[$i]);
}
}
}
@ -316,7 +317,7 @@ class ImportXml extends ImportPlugin
if ($data_present) {
/**
* Set values to NULL if they were not present
* to maintain PMA_buildSQL() call integrity
* to maintain Import::buildSql() call integrity
*/
if (!isset($analyses)) {
$analyses = null;
@ -358,13 +359,13 @@ class ImportXml extends ImportPlugin
}
/* Created and execute necessary SQL statements from data */
PMA_buildSQL($db_name, $tables, $analyses, $create, $options, $sql_data);
Import::buildSql($db_name, $tables, $analyses, $create, $options, $sql_data);
unset($analyses);
unset($tables);
unset($create);
/* Commit any possible data in buffers */
PMA_importRunQuery('', '', $sql_data);
Import::runQuery('', '', $sql_data);
}
}

View File

@ -12,6 +12,7 @@ gettext mechanism, see https://wiki.phpmyadmin.net/pma/Gettext_for_developers.
*/
namespace PhpMyAdmin\Plugins\Import;
use PhpMyAdmin\Import;
use PhpMyAdmin\Plugins\ImportPlugin;
/**
@ -104,7 +105,7 @@ class Import[Name] extends ImportPlugin
$buffer = '';
while (! ($finished && $i >= $len) && ! $error && ! $timeout_passed) {
$data = PMA_importGetNextChunk();
$data = Import::getNextChunk();
if ($data === false) {
// subtract data we didn't handle yet and stop processing
$GLOBALS['offset'] -= strlen($buffer);
@ -116,10 +117,10 @@ class Import[Name] extends ImportPlugin
$buffer .= $data;
}
// PARSE $buffer here, post sql queries using:
PMA_importRunQuery($sql, $verbose_sql_with_comments, $sql_data);
Import::runQuery($sql, $verbose_sql_with_comments, $sql_data);
} // End of import loop
// Commit any possible data in buffers
PMA_importRunQuery('', '', $sql_data);
Import::runQuery('', '', $sql_data);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,16 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_checkTimeout()
* from libraries/import.lib.php
* Test for PhpMyAdmin\Import
*
* @package PhpMyAdmin-test
*/
use PhpMyAdmin\Url;
namespace PhpMyAdmin\Tests;
/*
* Include to test.
*/
use PhpMyAdmin\Import;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
/*
* we must set $GLOBALS['server'] here
@ -21,17 +21,14 @@ $GLOBALS['server'] = 0;
/*
* Include to test.
*/
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
/**
* Tests for import functions
*
* @package PhpMyAdmin-test
*/
class PMA_Import_Test extends PHPUnit_Framework_TestCase
class ImportTest extends \PHPUnit_Framework_TestCase
{
/**
* Prepares environment for the test.
@ -44,7 +41,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_checkTimeout
* Test for Import::checkTimeout
*
* @return void
*/
@ -57,39 +54,39 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
$maximum_time = 0;
$timeout_passed = false;
$this->assertFalse(PMA_checkTimeout());
$this->assertFalse(Import::checkTimeout());
//Reinit values.
$timestamp = time();
$maximum_time = 0;
$timeout_passed = true;
$this->assertFalse(PMA_checkTimeout());
$this->assertFalse(Import::checkTimeout());
//Reinit values.
$timestamp = time();
$maximum_time = 30;
$timeout_passed = true;
$this->assertTrue(PMA_checkTimeout());
$this->assertTrue(Import::checkTimeout());
//Reinit values.
$timestamp = time()-15;
$maximum_time = 30;
$timeout_passed = false;
$this->assertFalse(PMA_checkTimeout());
$this->assertFalse(Import::checkTimeout());
//Reinit values.
$timestamp = time()-60;
$maximum_time = 30;
$timeout_passed = false;
$this->assertTrue(PMA_checkTimeout());
$this->assertTrue(Import::checkTimeout());
}
/**
* Test for PMA_lookForUse
* Test for Import::lookForUse
*
* @return void
*/
@ -97,42 +94,42 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
{
$this->assertEquals(
array(null, null),
PMA_lookForUse(null, null, null)
Import::lookForUse(null, null, null)
);
$this->assertEquals(
array('myDb', null),
PMA_lookForUse(null, 'myDb', null)
Import::lookForUse(null, 'myDb', null)
);
$this->assertEquals(
array('myDb', true),
PMA_lookForUse(null, 'myDb', true)
Import::lookForUse(null, 'myDb', true)
);
$this->assertEquals(
array('myDb', true),
PMA_lookForUse('select 1 from myTable', 'myDb', true)
Import::lookForUse('select 1 from myTable', 'myDb', true)
);
$this->assertEquals(
array('anotherDb', true),
PMA_lookForUse('use anotherDb', 'myDb', false)
Import::lookForUse('use anotherDb', 'myDb', false)
);
$this->assertEquals(
array('anotherDb', true),
PMA_lookForUse('use anotherDb', 'myDb', true)
Import::lookForUse('use anotherDb', 'myDb', true)
);
$this->assertEquals(
array('anotherDb', true),
PMA_lookForUse('use `anotherDb`;', 'myDb', true)
Import::lookForUse('use `anotherDb`;', 'myDb', true)
);
}
/**
* Test for PMA_getColumnAlphaName
* Test for Import::getColumnAlphaName
*
* @param string $expected Expected result of the function
* @param int $num The column number
@ -143,7 +140,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
*/
function testGetColumnAlphaName($expected, $num)
{
$this->assertEquals($expected, PMA_getColumnAlphaName($num));
$this->assertEquals($expected, Import::getColumnAlphaName($num));
}
/**
@ -164,7 +161,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_getColumnNumberFromName
* Test for Import::getColumnNumberFromName
*
* @param int $expected Expected result of the function
* @param string|null $name column name(i.e. "A", or "BC", etc.)
@ -175,7 +172,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
*/
function testGetColumnNumberFromName($expected, $name)
{
$this->assertEquals($expected, PMA_getColumnNumberFromName($name));
$this->assertEquals($expected, Import::getColumnNumberFromName($name));
}
/**
@ -196,7 +193,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_getDecimalPrecision
* Test for Import::getDecimalPrecision
*
* @param int $expected Expected result of the function
* @param string|null $size Size of field
@ -207,7 +204,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
*/
function testGetDecimalPrecision($expected, $size)
{
$this->assertEquals($expected, PMA_getDecimalPrecision($size));
$this->assertEquals($expected, Import::getDecimalPrecision($size));
}
/**
@ -226,7 +223,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_getDecimalScale
* Test for Import::getDecimalScale
*
* @param int $expected Expected result of the function
* @param string|null $size Size of field
@ -237,7 +234,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
*/
function testGetDecimalScale($expected, $size)
{
$this->assertEquals($expected, PMA_getDecimalScale($size));
$this->assertEquals($expected, Import::getDecimalScale($size));
}
/**
@ -256,7 +253,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_getDecimalSize
* Test for Import::getDecimalSize
*
* @param array $expected Expected result of the function
* @param string|null $cell Cell content
@ -267,7 +264,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
*/
function testGetDecimalSize($expected, $cell)
{
$this->assertEquals($expected, PMA_getDecimalSize($cell));
$this->assertEquals($expected, Import::getDecimalSize($cell));
}
/**
@ -286,7 +283,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_detectType
* Test for Import::detectType
*
* @param int $expected Expected result of the function
* @param int|null $type Last cumulative column type (VARCHAR or INT or
@ -300,7 +297,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
*/
function testDetectType($expected, $type, $cell)
{
$this->assertEquals($expected, PMA_detectType($type, $cell));
$this->assertEquals($expected, Import::detectType($type, $cell));
}
/**
@ -311,24 +308,24 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
function provDetectType()
{
return array(
array(NONE, null, 'NULL'),
array(NONE, NONE, 'NULL'),
array(INT, INT, 'NULL'),
array(VARCHAR, VARCHAR, 'NULL'),
array(VARCHAR, null, null),
array(VARCHAR, INT, null),
array(INT, INT, '10'),
array(DECIMAL, DECIMAL, '10.2'),
array(DECIMAL, INT, '10.2'),
array(BIGINT, BIGINT, '2147483648'),
array(BIGINT, INT, '2147483648'),
array(VARCHAR, VARCHAR, 'test'),
array(VARCHAR, INT, 'test'),
array(Import::NONE, null, 'NULL'),
array(Import::NONE, Import::NONE, 'NULL'),
array(Import::INT, Import::INT, 'NULL'),
array(Import::VARCHAR, Import::VARCHAR, 'NULL'),
array(Import::VARCHAR, null, null),
array(Import::VARCHAR, Import::INT, null),
array(Import::INT, Import::INT, '10'),
array(Import::DECIMAL, Import::DECIMAL, '10.2'),
array(Import::DECIMAL, Import::INT, '10.2'),
array(Import::BIGINT, Import::BIGINT, '2147483648'),
array(Import::BIGINT, Import::INT, '2147483648'),
array(Import::VARCHAR, Import::VARCHAR, 'test'),
array(Import::VARCHAR, Import::INT, 'test'),
);
}
/**
* Test for PMA_getMatchedRows.
* Test for Import::getMatchedRows.
*
* @return void
*/
@ -385,14 +382,14 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
*/
function simulatedQueryTest($sql_query, $simulated_query)
{
$parser = new PhpMyAdmin\SqlParser\Parser($sql_query);
$parser = new Parser($sql_query);
$analyzed_sql_results = array(
'query' => $sql_query,
'parser' => $parser,
'statement' => $parser->statements[0],
);
$simulated_data = PMA_getMatchedRows($analyzed_sql_results);
$simulated_data = Import::getMatchedRows($analyzed_sql_results);
// URL to matched rows.
$_url_params = array(
@ -403,7 +400,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
array(
'sql_query' => PhpMyAdmin\Util::formatSql(
'sql_query' => Util::formatSql(
$analyzed_sql_results['query']
),
'matched_rows' => 2,
@ -414,7 +411,7 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_checkIfRollbackPossible
* Test for Import::checkIfRollbackPossible
*
* @return void
*/
@ -482,6 +479,6 @@ class PMA_Import_Test extends PHPUnit_Framework_TestCase
. 'SET `table_1`.`id` = `table_2`.`id` '
. 'WHERE 1';
$this->assertEquals(true, PMA_checkIfRollbackPossible($sql_query));
$this->assertEquals(true, Import::checkIfRollbackPossible($sql_query));
}
}

View File

@ -19,7 +19,6 @@ $GLOBALS['server'] = 0;
* Include to test.
*/
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -19,7 +19,6 @@ $GLOBALS['plugin_param'] = "table";
* Include to test.
*/
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -17,7 +17,6 @@ $GLOBALS['server'] = 0;
* Include to test.
*/
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -18,7 +18,6 @@ $GLOBALS['server'] = 0;
* Include to test.
*/
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -15,7 +15,6 @@ use PhpMyAdmin\File;
$GLOBALS['server'] = 0;
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -18,7 +18,6 @@ $GLOBALS['server'] = 0;
* Include to test.
*/
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'test/PMATestCase.php';
/**

View File

@ -18,7 +18,6 @@ $GLOBALS['server'] = 0;
* Include to test.
*/
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/import.lib.php';
require_once 'test/PMATestCase.php';
/**