diff --git a/test/classes/plugin/import/ImportShp_test.php b/test/classes/plugin/import/ImportShp_test.php
index 632438975e..ee1e824b11 100644
--- a/test/classes/plugin/import/ImportShp_test.php
+++ b/test/classes/plugin/import/ImportShp_test.php
@@ -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()
diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php
index 9c776e7246..60e8314b2f 100644
--- a/test/classes/plugin/import/ImportXml_test.php
+++ b/test/classes/plugin/import/ImportXml_test.php
@@ -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']
+ );
+
+ }
}
+
+
+
diff --git a/test/classes/plugin/transformations/Image_JPEG_Inline_test.php b/test/classes/plugin/transformations/Image_JPEG_Inline_test.php
index c6bf786dcc..854267ce3c 100644
--- a/test/classes/plugin/transformations/Image_JPEG_Inline_test.php
+++ b/test/classes/plugin/transformations/Image_JPEG_Inline_test.php
@@ -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 = '
';
+ $result = '
';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
diff --git a/test/classes/plugin/transformations/Image_PNG_Inline_test.php b/test/classes/plugin/transformations/Image_PNG_Inline_test.php
index b97181b5a3..e031566447 100644
--- a/test/classes/plugin/transformations/Image_PNG_Inline_test.php
+++ b/test/classes/plugin/transformations/Image_PNG_Inline_test.php
@@ -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 = '
';
+ $result = '
';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
diff --git a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php
index dc677127ab..e06b5ccb14 100644
--- a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php
+++ b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php
@@ -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 = ''
- . 'Jan 01, 1970 at 04:25 AM';
+ . 'Jan 01, 1970 at 03:25 AM';
$this->assertEquals(
$result,
$this->object->applyTransformation($timestamp, $options, $meta)
diff --git a/test/test_data/phpmyadmin_importXML_For_Testing.xml b/test/test_data/phpmyadmin_importXML_For_Testing.xml
new file mode 100644
index 0000000000..60ef4d7aa2
--- /dev/null
+++ b/test/test_data/phpmyadmin_importXML_For_Testing.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+ 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';
+
+
+
+
+
+
+
+
+ 1
+ pma_dbase
+
+ pma_label
+ SELECT * FROM `db_content` WHERE 1
+
+
+
\ No newline at end of file