add real test case for import MediaWiki Database
This commit is contained in:
parent
2a5463f6c0
commit
c6eed3f5b2
@ -4,10 +4,21 @@
|
||||
*
|
||||
* @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/ImportMediawiki.class.php';
|
||||
@ -35,8 +46,23 @@ class ImportMediawiki_Test extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['plugin_param'] = 'table';
|
||||
$this->object = new ImportMediawiki();
|
||||
$GLOBALS['plugin_param'] = 'database';
|
||||
$this->object = new ImportMediawiki();
|
||||
|
||||
//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.mediawiki';
|
||||
$GLOBALS['import_text'] = 'ImportMediawiki_Test';
|
||||
$GLOBALS['compression'] = 'none';
|
||||
$GLOBALS['read_multiply'] = 10;
|
||||
$GLOBALS['import_type'] = 'Mediawiki';
|
||||
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,4 +109,65 @@ class ImportMediawiki_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
|
||||
|
||||
mediawiki_DB (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: `mediawiki_DB`',
|
||||
$import_notice
|
||||
);
|
||||
$this->assertContains(
|
||||
'Edit settings for `mediawiki_DB`',
|
||||
$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']
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
16
test/test_data/phpmyadmin.mediawiki
Normal file
16
test/test_data/phpmyadmin.mediawiki
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
<!--
|
||||
Table data for `pma_bookmarktest`
|
||||
-->
|
||||
|
||||
{| class="wikitable sortable" style="text-align:center;"
|
||||
! table header
|
||||
|+'''pma_bookmarktest'''
|
||||
|-
|
||||
| 1
|
||||
| dbbase
|
||||
|
|
||||
| ddd
|
||||
| SELECT * FROM `db_content` WHERE 1
|
||||
|}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user