Skip to content

Commit

Permalink
Test for table renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Oct 19, 2012
1 parent 7c39740 commit c9d2791
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libraries/dbi/dummy.lib.php
Expand Up @@ -213,6 +213,14 @@
'query' => 'SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.`TABLE_PRIVILEGES` WHERE GRANTEE=\'\'\'pma_test\'\'@\'\'localhost\'\'\' AND PRIVILEGE_TYPE=\'EVENT\' AND TABLE_SCHEMA=\'pma\\\\_test\' AND TABLE_NAME=\'table1\'',
'result' => array(),
),
array(
'query' => 'RENAME TABLE `table1`.`pma_test` TO `table1`.`table3`;',
'result' => array(),
),
array(
'query' => 'SELECT TRIGGER_SCHEMA, TRIGGER_NAME, EVENT_MANIPULATION, EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT, EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER FROM information_schema.TRIGGERS WHERE TRIGGER_SCHEMA= \'table1\' AND EVENT_OBJECT_TABLE = \'pma_test\';',
'result' => array(),
),

);
/**
Expand Down
40 changes: 40 additions & 0 deletions test/classes/PMA_Table_test.php
Expand Up @@ -10,6 +10,14 @@
*/

require_once 'libraries/Table.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/database_interface.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/Theme.class.php';
require_once 'libraries/Tracker.class.php';
require_once 'libraries/relation.lib.php';


/**
* Tests behaviour of PMA_Table class
Expand All @@ -18,6 +26,27 @@
*/
class PMA_Table_Test extends PHPUnit_Framework_TestCase
{
/**
* Configures environment
*
* @return void
*/
protected function setUp()
{
$GLOBALS['server'] = 0;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['ServerDefault'] = 1;
$GLOBALS['lang'] = 'en';
$_SESSION[' PMA_token '] = 'token';
$GLOBALS['cfg']['MySQLManualType'] = 'viewable';
$GLOBALS['cfg']['MySQLManualBase'] = 'http://dev.mysql.com/doc/refman';
$GLOBALS['cfg']['PropertiesIconic'] = 'both';
$_SESSION['PMA_Theme'] = new PMA_Theme();
$GLOBALS['pmaThemeImage'] = 'themes/dot.gif';
$GLOBALS['is_ajax_request'] = false;
$GLOBALS['cfgRelation'] = PMA_getRelationsParam();
}

/**
* Test object creating
*
Expand All @@ -29,5 +58,16 @@ public function testCreate()
$this->assertInstanceOf('PMA_Table', $table);
}

/**
* Test renaming
*
* @return void
*/
public function testRename()
{
$table = new PMA_Table('pma_test', 'table1');
$table->rename('table3');
$this->assertEquals('table3', $table->getName());
}
}

0 comments on commit c9d2791

Please sign in to comment.