From 43a9886aa3121eac21991a613fca0c9cdce5b097 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Sat, 15 Jun 2013 22:06:15 +0800 Subject: [PATCH 01/12] add doImport real case --- test/classes/plugin/import/ImportXml_test.php | 76 ++++++++++++++++++- .../phpmyadmin_importXML_For_Testing.xml | 45 +++++++++++ 2 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index 9c776e7246..7d4f2fcc00 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -12,7 +12,7 @@ /* Each PluginObserver instance contains a PluginManager instance */ require_once 'libraries/plugins/import/ImportXml.class.php'; require_once 'libraries/Util.class.php'; - +require_once 'libraries/database_interface.inc.php'; /** * Tests for ImportXml class @@ -35,7 +35,23 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = new ImportXml(); + global $compression, $import_handle, $read_multiply, $cfg; + + $this->object = new ImportXml(); + + //setting + $GLOBALS['finished'] = false; + $GLOBALS['read_limit'] = 100000000; + $GLOBALS['import_file'] = 'test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml'; + $GLOBALS['import_text'] = 'ImportXml_Test'; + $compression = 'none'; + $GLOBALS['offset'] = 0; + $read_multiply = 10; + $import_file = 'test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml'; + $import_type = 'Xml'; + $import_handle = @fopen($import_file, 'r'); + $cfg['AllowUserDropDatabase'] = false; + $GLOBALS['cfg']['Server']['DisableIS'] = true; } /** @@ -82,4 +98,60 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase ); } + + /** + * Test for doImport + * + * @return void + * + * @group medium + */ + public function testDoImport() + { + global $import_notice; + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + $dbi->expects($this->once()) + ->method('isSuperuser') + ->with('true'); + $GLOBALS['dbi'] = $dbi; + $this->object->doImport(); + + //If import successfully, PMA will show all database 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 + + phpmyadmin (Options) + p ma_bookmark (Structure) (Options) + */ + $import_succesful_display_message = + '

The following structures have either ' + . 'been created or altered. Here you can:
'; + + //asset that all databases and tables are imported + $this->assertEquals( + $import_succesful_display_message, + $import_notice + ); + $this->assertEquals( + true, + $GLOBALS['finished'] + ); + + } } diff --git a/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml b/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml new file mode 100644 index 0000000000..e07f4304bf --- /dev/null +++ b/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml @@ -0,0 +1,45 @@ + + + + + + + + + CREATE TABLE `pma_bookmark` ( + `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 + okjoomla.com + + chen + SELECT * FROM `db_content` WHERE 1 +
+
+
\ No newline at end of file From e0eccfbaf927e812dd130aefbd1f8ac082244639 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Sun, 16 Jun 2013 00:15:53 +0800 Subject: [PATCH 02/12] format the output html --- test/classes/plugin/import/ImportXml_test.php | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index 7d4f2fcc00..4d19018138 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -44,14 +44,16 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase $GLOBALS['read_limit'] = 100000000; $GLOBALS['import_file'] = 'test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml'; $GLOBALS['import_text'] = 'ImportXml_Test'; - $compression = 'none'; $GLOBALS['offset'] = 0; + $GLOBALS['cfg']['Server']['DisableIS'] = true; + + //global variable + $compression = 'none'; $read_multiply = 10; $import_file = 'test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml'; $import_type = 'Xml'; $import_handle = @fopen($import_file, 'r'); $cfg['AllowUserDropDatabase'] = false; - $GLOBALS['cfg']['Server']['DisableIS'] = true; } /** @@ -108,17 +110,22 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase */ public function testDoImport() { + //$import_notice will show the import detail result global $import_notice; + + //mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $dbi->expects($this->once()) - ->method('isSuperuser') - ->with('true'); + ->method('isSuperuser') + ->with(true); $GLOBALS['dbi'] = $dbi; + + //Test function called $this->object->doImport(); - //If import successfully, PMA will show all database and tables imported as following HTML Page + //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 @@ -126,22 +133,26 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase Edit structure by following the "Structure" link phpmyadmin (Options) - p ma_bookmark (Structure) (Options) + pma_bookmark (Structure) (Options) */ $import_succesful_display_message = '

The following structures have either ' - . 'been created or altered. Here you can:
'; //asset that all databases and tables are imported $this->assertEquals( From 82e361376c42433df75a0035693b173600916124 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Sun, 16 Jun 2013 12:01:24 +0800 Subject: [PATCH 03/12] refactor the output format --- libraries/check_user_privileges.lib.php | 2 +- libraries/import.lib.php | 3 + libraries/plugins/import/ImportXml.class.php | 8 +++ test/classes/plugin/import/ImportXml_test.php | 57 +++++++++++-------- .../phpmyadmin_importXML_For_Testing.xml | 18 +++--- 5 files changed, 53 insertions(+), 35 deletions(-) diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index 8d97f37a84..f7e732a22e 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) { /** * */ -$GLOBALS['is_superuser'] = $GLOBALS['dbi']->isSuperuser(); +$GLOBALS['is_superuser'] = isset($GLOBALS['dbi'])? $GLOBALS['dbi']->isSuperuser() : false; /** * sets privilege information extracted from SHOW GRANTS result diff --git a/libraries/import.lib.php b/libraries/import.lib.php index c02bb8b969..eed7196f59 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -14,6 +14,9 @@ if (! defined('PHPMYADMIN')) { */ require_once './libraries/check_user_privileges.lib.php'; +if (!function_exists('PMA_generate_common_url')) { + require_once './libraries/url_generating.lib.php'; +} /** * We do this check, DROP DATABASE does not need to be confirmed elsewhere */ diff --git a/libraries/plugins/import/ImportXml.class.php b/libraries/plugins/import/ImportXml.class.php index 9c0e999592..f125bc2494 100644 --- a/libraries/plugins/import/ImportXml.class.php +++ b/libraries/plugins/import/ImportXml.class.php @@ -22,6 +22,14 @@ if (!function_exists('libxml_disable_entity_loader')) { /* Get the import interface */ require_once 'libraries/plugins/ImportPlugin.class.php'; +if (!function_exists('PMA_importGetNextChunk')) { + require_once 'libraries/import.lib.php'; +} + +if (!class_exists('PMA_Table')) { + require_once 'libraries/Table.class.php'; +} + /** * Handles the import for the XML format * diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index 4d19018138..b71a840275 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -2,7 +2,7 @@ /** * Tests for ImportXml class * - * @package PhpMyAdmin-test + * @package phpmyadmin-test */ /* @@ -17,7 +17,7 @@ require_once 'libraries/database_interface.inc.php'; /** * Tests for ImportXml class * - * @package PhpMyAdmin-test + * @package phpmyadmin-test */ class ImportXml_Test extends PHPUnit_Framework_TestCase { @@ -45,7 +45,7 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase $GLOBALS['import_file'] = 'test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml'; $GLOBALS['import_text'] = 'ImportXml_Test'; $GLOBALS['offset'] = 0; - $GLOBALS['cfg']['Server']['DisableIS'] = true; + $GLOBALS['cfg']['Server']['DisableIS'] = false; //global variable $compression = 'none'; @@ -111,15 +111,12 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase public function testDoImport() { //$import_notice will show the import detail result - global $import_notice; + global $import_notice; - //mock DBI + //Mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() ->getMock(); - $dbi->expects($this->once()) - ->method('isSuperuser') - ->with(true); $GLOBALS['dbi'] = $dbi; //Test function called @@ -132,27 +129,37 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase Change any of its settings by clicking the corresponding "Options" link Edit structure by following the "Structure" link - phpmyadmin (Options) - pma_bookmark (Structure) (Options) + phpmyadmintest (Options) + pma_bookmarktest (Structure) (Options) */ $import_succesful_display_message = '

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
  • ' + . 'been created or altered. Here you can:' . '
    ' - . '
  • phpmyadmin (Options)
  • ' - . '
'; + + . '
    ' + . '
  • 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)' + . '
  • ' + + . '' + . '
'; //asset that all databases and tables are imported $this->assertEquals( diff --git a/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml b/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml index e07f4304bf..60ef4d7aa2 100644 --- a/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml +++ b/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml @@ -15,9 +15,9 @@ - Structure schemas --> - - - CREATE TABLE `pma_bookmark` ( + + + 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 '', @@ -30,15 +30,15 @@ - - - + + +
1 - okjoomla.com + pma_dbase - chen + pma_labelSELECT * FROM `db_content` WHERE 1
From f7051156a24d4fcea2df7573236477d4f0af894b Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Sun, 16 Jun 2013 12:11:03 +0800 Subject: [PATCH 04/12] fix the timezone difference --- .../plugin/transformations/Text_Plain_Dateformat_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php index dc677127ab..54cff24e33 100644 --- a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php @@ -134,7 +134,7 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase $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) From 336d18cdbc95c322e1ab176cd720d4ba9dbae233 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Sun, 16 Jun 2013 12:20:00 +0800 Subject: [PATCH 05/12] remove unneeded case --- test/classes/plugin/import/ImportShp_test.php | 4 ---- 1 file changed, 4 deletions(-) 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() From 98520eac2976807cb8ab3ee9a87ba866b0b03ebf Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Sun, 16 Jun 2013 13:09:34 +0800 Subject: [PATCH 06/12] keep code consistence --- test/classes/plugin/import/ImportXml_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index b71a840275..753d2592cb 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -2,7 +2,7 @@ /** * Tests for ImportXml class * - * @package phpmyadmin-test + * @package PhpMyAdmin-test */ /* @@ -17,7 +17,7 @@ require_once 'libraries/database_interface.inc.php'; /** * Tests for ImportXml class * - * @package phpmyadmin-test + * @package PhpMyAdmin-test */ class ImportXml_Test extends PHPUnit_Framework_TestCase { From 4b0abc19774c6717ad60abf5e18ae457454922cb Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Mon, 17 Jun 2013 23:35:07 +0800 Subject: [PATCH 07/12] 1. move test data to test_data dir 2. refactor the require_once --- libraries/check_user_privileges.lib.php | 2 +- libraries/import.lib.php | 3 --- libraries/plugins/import/ImportXml.class.php | 7 ------ test/classes/plugin/import/ImportXml_test.php | 23 +++++++++++++++---- .../phpmyadmin_importXML_For_Testing.xml | 0 5 files changed, 19 insertions(+), 16 deletions(-) rename test/{classes/plugin/import => test_data}/phpmyadmin_importXML_For_Testing.xml (100%) diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index f7e732a22e..8d97f37a84 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) { /** * */ -$GLOBALS['is_superuser'] = isset($GLOBALS['dbi'])? $GLOBALS['dbi']->isSuperuser() : false; +$GLOBALS['is_superuser'] = $GLOBALS['dbi']->isSuperuser(); /** * sets privilege information extracted from SHOW GRANTS result diff --git a/libraries/import.lib.php b/libraries/import.lib.php index eed7196f59..c02bb8b969 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -14,9 +14,6 @@ if (! defined('PHPMYADMIN')) { */ require_once './libraries/check_user_privileges.lib.php'; -if (!function_exists('PMA_generate_common_url')) { - require_once './libraries/url_generating.lib.php'; -} /** * We do this check, DROP DATABASE does not need to be confirmed elsewhere */ diff --git a/libraries/plugins/import/ImportXml.class.php b/libraries/plugins/import/ImportXml.class.php index f125bc2494..4a7e6f4a2f 100644 --- a/libraries/plugins/import/ImportXml.class.php +++ b/libraries/plugins/import/ImportXml.class.php @@ -22,13 +22,6 @@ if (!function_exists('libxml_disable_entity_loader')) { /* Get the import interface */ require_once 'libraries/plugins/ImportPlugin.class.php'; -if (!function_exists('PMA_importGetNextChunk')) { - require_once 'libraries/import.lib.php'; -} - -if (!class_exists('PMA_Table')) { - require_once 'libraries/Table.class.php'; -} /** * Handles the import for the XML format diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index 753d2592cb..e71916e357 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'; -require_once 'libraries/database_interface.inc.php'; /** * Tests for ImportXml class @@ -42,15 +51,16 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase //setting $GLOBALS['finished'] = false; $GLOBALS['read_limit'] = 100000000; - $GLOBALS['import_file'] = 'test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml'; + $GLOBALS['import_file'] = 'test/test_data/phpmyadmin_importXML_For_Testing.xml'; $GLOBALS['import_text'] = 'ImportXml_Test'; $GLOBALS['offset'] = 0; $GLOBALS['cfg']['Server']['DisableIS'] = false; + $GLOBALS['cfg']['ServerDefault'] = 0; //global variable $compression = 'none'; $read_multiply = 10; - $import_file = 'test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml'; + $import_file = 'test/test_data/phpmyadmin_importXML_For_Testing.xml'; $import_type = 'Xml'; $import_handle = @fopen($import_file, 'r'); $cfg['AllowUserDropDatabase'] = false; @@ -173,3 +183,6 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase } } + + + diff --git a/test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml b/test/test_data/phpmyadmin_importXML_For_Testing.xml similarity index 100% rename from test/classes/plugin/import/phpmyadmin_importXML_For_Testing.xml rename to test/test_data/phpmyadmin_importXML_For_Testing.xml From cdfb0b890d2547c25e7d9da92d6a3dccc7055579 Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Mon, 17 Jun 2013 23:49:04 +0800 Subject: [PATCH 08/12] fix the assertion due to PMA_IS_GD2 setting --- libraries/plugins/import/ImportXml.class.php | 1 - .../plugin/transformations/Image_JPEG_Inline_test.php | 6 ++++-- .../plugin/transformations/Image_PNG_Inline_test.php | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/plugins/import/ImportXml.class.php b/libraries/plugins/import/ImportXml.class.php index 4a7e6f4a2f..9c0e999592 100644 --- a/libraries/plugins/import/ImportXml.class.php +++ b/libraries/plugins/import/ImportXml.class.php @@ -22,7 +22,6 @@ if (!function_exists('libxml_disable_entity_loader')) { /* Get the import interface */ require_once 'libraries/plugins/ImportPlugin.class.php'; - /** * Handles the import for the XML format * 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 = 'PMA_JPEG_Inline'; + $result = 'PMA_JPEG_Inline'; $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 = 'PMA_PNG_Inline'; + $result = ''; $this->assertEquals( $result, $this->object->applyTransformation($buffer, $options) From f4e230b180ef4d31b538f34156f1a71170291dae Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Tue, 18 Jun 2013 09:35:45 +0800 Subject: [PATCH 09/12] add timezone setting for Text_Plain_Dateformat --- .../plugin/transformations/Text_Plain_Dateformat_test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php index 54cff24e33..e06b5ccb14 100644 --- a/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php +++ b/test/classes/plugin/transformations/Text_Plain_Dateformat_test.php @@ -129,6 +129,8 @@ 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(); From 589f75976f8e03879f508c46cbc6f1f69249017e Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Tue, 18 Jun 2013 15:24:42 +0800 Subject: [PATCH 10/12] change to assertion to import string but not all string since it will be changed frequently --- test/classes/plugin/import/ImportXml_test.php | 54 ++++++++----------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index e71916e357..a1852955e2 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -141,41 +141,29 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase phpmyadmintest (Options) pma_bookmarktest (Structure) (Options) - */ - $import_succesful_display_message = - '

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)' - . '
  • ' - - . '' - . '
'; - + */ + //asset that all databases and tables are imported - $this->assertEquals( - $import_succesful_display_message, + $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'] From 646329bdde1e4dfd93258e3eb67f34baf3fcf87d Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Tue, 18 Jun 2013 16:35:52 +0800 Subject: [PATCH 11/12] using GLOBAL instead of global for code concurrency --- test/classes/plugin/import/ImportXml_test.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index a1852955e2..68455eb9ce 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -51,19 +51,17 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase //setting $GLOBALS['finished'] = false; $GLOBALS['read_limit'] = 100000000; - $GLOBALS['import_file'] = 'test/test_data/phpmyadmin_importXML_For_Testing.xml'; - $GLOBALS['import_text'] = 'ImportXml_Test'; $GLOBALS['offset'] = 0; $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['cfg']['ServerDefault'] = 0; + $GLOBALS['cfg']['AllowUserDropDatabase'] = false; - //global variable - $compression = 'none'; - $read_multiply = 10; - $import_file = 'test/test_data/phpmyadmin_importXML_For_Testing.xml'; - $import_type = 'Xml'; - $import_handle = @fopen($import_file, 'r'); - $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'); } /** From f8cc20528572cb31a6e1a41173f41d0e8f00df3c Mon Sep 17 00:00:00 2001 From: adamgsoc2013 Date: Tue, 18 Jun 2013 16:39:35 +0800 Subject: [PATCH 12/12] using GLOBAL for code concurrency --- test/classes/plugin/import/ImportXml_test.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/classes/plugin/import/ImportXml_test.php b/test/classes/plugin/import/ImportXml_test.php index 68455eb9ce..60e8314b2f 100644 --- a/test/classes/plugin/import/ImportXml_test.php +++ b/test/classes/plugin/import/ImportXml_test.php @@ -43,9 +43,7 @@ class ImportXml_Test extends PHPUnit_Framework_TestCase * @return void */ protected function setUp() - { - global $compression, $import_handle, $read_multiply, $cfg; - + { $this->object = new ImportXml(); //setting