Merge branch 'master' of github.com:phpmyadmin/phpmyadmin
This commit is contained in:
commit
4782d61fbf
@ -69,10 +69,6 @@ class ImportShp_Test extends PHPUnit_Framework_TestCase
|
||||
'shp',
|
||||
$properties->getExtension()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'text/plain',
|
||||
$properties->getMimeType()
|
||||
);
|
||||
$this->assertEquals(
|
||||
array(),
|
||||
$properties->getOptions()
|
||||
|
||||
@ -4,15 +4,24 @@
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* we must set $GLOBALS['server'] here
|
||||
* since 'check_user_privileges.lib.php' will use it globally
|
||||
*/
|
||||
$GLOBALS['server'] = 0;
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/Util.class.php';
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/Table.class.php';
|
||||
require_once 'libraries/database_interface.inc.php';
|
||||
require_once 'libraries/import.lib.php';
|
||||
/* Each PluginObserver instance contains a PluginManager instance */
|
||||
require_once 'libraries/plugins/import/ImportXml.class.php';
|
||||
require_once 'libraries/Util.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Tests for ImportXml class
|
||||
@ -34,8 +43,23 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = new ImportXml();
|
||||
{
|
||||
$this->object = new ImportXml();
|
||||
|
||||
//setting
|
||||
$GLOBALS['finished'] = false;
|
||||
$GLOBALS['read_limit'] = 100000000;
|
||||
$GLOBALS['offset'] = 0;
|
||||
$GLOBALS['cfg']['Server']['DisableIS'] = false;
|
||||
$GLOBALS['cfg']['ServerDefault'] = 0;
|
||||
$GLOBALS['cfg']['AllowUserDropDatabase'] = false;
|
||||
|
||||
$GLOBALS['import_file'] = 'test/test_data/phpmyadmin_importXML_For_Testing.xml';
|
||||
$GLOBALS['import_text'] = 'ImportXml_Test';
|
||||
$GLOBALS['compression'] = 'none';
|
||||
$GLOBALS['read_multiply'] = 10;
|
||||
$GLOBALS['import_type'] = 'Xml';
|
||||
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,4 +106,67 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for doImport
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @group medium
|
||||
*/
|
||||
public function testDoImport()
|
||||
{
|
||||
//$import_notice will show the import detail result
|
||||
global $import_notice;
|
||||
|
||||
//Mock DBI
|
||||
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
//Test function called
|
||||
$this->object->doImport();
|
||||
|
||||
//If import successfully, PMA will show all databases and tables imported as following HTML Page
|
||||
/*
|
||||
The following structures have either been created or altered. Here you can:
|
||||
View a structure's contents by clicking on its name
|
||||
Change any of its settings by clicking the corresponding "Options" link
|
||||
Edit structure by following the "Structure" link
|
||||
|
||||
phpmyadmintest (Options)
|
||||
pma_bookmarktest (Structure) (Options)
|
||||
*/
|
||||
|
||||
//asset that all databases and tables are imported
|
||||
$this->assertContains(
|
||||
'The following structures have either been created or altered.',
|
||||
$import_notice
|
||||
);
|
||||
$this->assertContains(
|
||||
'Go to database: `phpmyadmintest`',
|
||||
$import_notice
|
||||
);
|
||||
$this->assertContains(
|
||||
'Edit settings for `phpmyadmintest`',
|
||||
$import_notice
|
||||
);
|
||||
$this->assertContains(
|
||||
'Go to table: `pma_bookmarktest`',
|
||||
$import_notice
|
||||
);
|
||||
$this->assertContains(
|
||||
'Edit settings for `pma_bookmarktest`',
|
||||
$import_notice
|
||||
);
|
||||
$this->assertEquals(
|
||||
true,
|
||||
$GLOBALS['finished']
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -124,8 +124,10 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$buffer = "PMA_JPEG_Inline";
|
||||
$options = array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link");
|
||||
$result = '<img src="transformation_wrapper.phpPMA_wrapper_link"'
|
||||
. ' alt="PMA_JPEG_Inline" width="320" height="240" />';
|
||||
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link" '
|
||||
. 'target="_blank"><img src="transformation_wrapper.php'
|
||||
. 'PMA_wrapper_link&resize=jpeg&newWidth=./image/&'
|
||||
. 'newHeight=200" alt="PMA_JPEG_Inline" border="0" /></a>';
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
|
||||
@ -124,8 +124,10 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$buffer = "PMA_PNG_Inline";
|
||||
$options = array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link");
|
||||
$result = '<img src="transformation_wrapper.phpPMA_wrapper_link"'
|
||||
. ' alt="PMA_PNG_Inline" width="320" height="240" />';
|
||||
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link"'
|
||||
. ' target="_blank"><img src="transformation_wrapper.phpPMA_wrapper_link&'
|
||||
. 'resize=jpeg&newWidth=./image/&newHeight=200" '
|
||||
. 'alt="PMA_PNG_Inline" border="0" /></a>';
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($buffer, $options)
|
||||
|
||||
@ -129,12 +129,14 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testApplyTransformation()
|
||||
{
|
||||
//add timezone setting before time transformation
|
||||
date_default_timezone_set('UTC');
|
||||
$timestamp = 12345;
|
||||
$options = array(0);
|
||||
$meta = new Text_Plain_Dateformat_Meta();
|
||||
$meta->type = 'int';
|
||||
$result = '<dfn onclick="alert(\'12345\');" title="12345">'
|
||||
. 'Jan 01, 1970 at 04:25 AM</dfn>';
|
||||
. 'Jan 01, 1970 at 03:25 AM</dfn>';
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->object->applyTransformation($timestamp, $options, $meta)
|
||||
|
||||
45
test/test_data/phpmyadmin_importXML_For_Testing.xml
Normal file
45
test/test_data/phpmyadmin_importXML_For_Testing.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
- phpMyAdmin XML Dump FOR testing
|
||||
- version 4.1-dev
|
||||
- http://www.phpmyadmin.net
|
||||
-
|
||||
- Host: 127.0.0.1
|
||||
- Generation Time: Jun 15, 2013 at 02:59 PM
|
||||
- Server version: 5.5.27-log
|
||||
- PHP Version: 5.4.7
|
||||
-->
|
||||
|
||||
<pma_xml_export version="1.0" xmlns:pma="http://www.phpmyadmin.net/some_doc_url/">
|
||||
<!--
|
||||
- Structure schemas
|
||||
-->
|
||||
<pma:structure_schemas>
|
||||
<pma:database name="phpmyadmintest" collation="utf8_bin" charset="utf8">
|
||||
<pma:table name="pma_bookmarktest">
|
||||
CREATE TABLE `pma_bookmarktest` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`dbase` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`user` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`label` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`query` text COLLATE utf8_bin NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Bookmarks';
|
||||
</pma:table>
|
||||
</pma:database>
|
||||
</pma:structure_schemas>
|
||||
|
||||
<!--
|
||||
- Database: 'phpmyadmintest'
|
||||
-->
|
||||
<database name="phpmyadmintest">
|
||||
<!-- Table pma_bookmarktest -->
|
||||
<table name="pma_bookmarktest">
|
||||
<column name="id">1</column>
|
||||
<column name="dbase">pma_dbase</column>
|
||||
<column name="user"></column>
|
||||
<column name="label">pma_label</column>
|
||||
<column name="query">SELECT * FROM `db_content` WHERE 1</column>
|
||||
</table>
|
||||
</database>
|
||||
</pma_xml_export>
|
||||
Loading…
Reference in New Issue
Block a user