Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-12-21 02:03:42 +01:00
commit 80a6279a16
11 changed files with 99 additions and 50 deletions

View File

@ -26,11 +26,14 @@ class AuthenticationConfigTest extends PmaTestCase
*
* @return void
*/
function setup()
protected function setUp()
{
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['token_provided'] = true;
$GLOBALS['token_mismatch'] = false;
$this->object = new AuthenticationConfig();

View File

@ -28,12 +28,15 @@ class AuthenticationHttpTest extends PmaTestCase
*
* @return void
*/
function setup()
protected function setUp()
{
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['cfg']['Servers'] = array();
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['lang'] = "en";
$GLOBALS['text_dir'] = "ltr";
$GLOBALS['token_provided'] = true;

View File

@ -25,11 +25,14 @@ class AuthenticationSignonTest extends PmaTestCase
*
* @return void
*/
function setup()
protected function setUp()
{
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$this->object = new AuthenticationSignon();
}

View File

@ -11,12 +11,6 @@ use PhpMyAdmin\Plugins\Import\ImportCsv;
use PhpMyAdmin\Tests\PmaTestCase;
use PhpMyAdmin\Theme;
/**
* we must set $GLOBALS['server'] here
* since 'check_user_privileges.inc.php' will use it globally
*/
$GLOBALS['server'] = 0;
/**
* Tests for PhpMyAdmin\Plugins\Import\ImportCsv class
*
@ -39,6 +33,7 @@ class ImportCsvTest extends PmaTestCase
*/
protected function setUp()
{
$GLOBALS['server'] = 0;
$GLOBALS['plugin_param'] = "csv";
$this->object = new ImportCsv();

View File

@ -10,13 +10,6 @@ use PhpMyAdmin\File;
use PhpMyAdmin\Plugins\Import\ImportLdi;
use PhpMyAdmin\Tests\PmaTestCase;
/*
* we must set $GLOBALS['server'] here
* since 'check_user_privileges.inc.php' will use it globally
*/
$GLOBALS['server'] = 0;
$GLOBALS['plugin_param'] = "table";
/**
* Tests for PhpMyAdmin\Plugins\Import\ImportLdi class
*
@ -29,6 +22,12 @@ class ImportLdiTest extends PmaTestCase
*/
protected $object;
/**
* @var \PhpMyAdmin\DatabaseInterface
* @access protected
*/
protected $dbi;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@ -39,6 +38,8 @@ class ImportLdiTest extends PmaTestCase
protected function setUp()
{
//setting
$GLOBALS['server'] = 0;
$GLOBALS['plugin_param'] = 'table';
$GLOBALS['finished'] = false;
$GLOBALS['read_limit'] = 100000000;
$GLOBALS['offset'] = 0;
@ -63,24 +64,10 @@ class ImportLdiTest extends PmaTestCase
$GLOBALS['table'] = "phpmyadmintest";
//Mock DBI
$dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
$this->dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->any())->method('tryQuery')
->will($this->returnValue(true));
$dbi->expects($this->any())->method('numRows')
->will($this->returnValue(10));
$fetchRowResult = array("ON");
$dbi->expects($this->any())->method('fetchRow')
->will($this->returnValue($fetchRowResult));
$dbi->expects($this->any())->method('escapeString')
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $dbi;
$GLOBALS['dbi'] = $this->dbi;
$this->object = new ImportLdi();
}
@ -126,6 +113,17 @@ class ImportLdiTest extends PmaTestCase
*/
public function testGetPropertiesAutoLdi()
{
$this->dbi->expects($this->any())->method('tryQuery')
->will($this->returnValue(true));
$this->dbi->expects($this->any())->method('numRows')
->will($this->returnValue(10));
$fetchRowResult = array("ON");
$this->dbi->expects($this->any())->method('fetchRow')
->will($this->returnValue($fetchRowResult));
$GLOBALS['dbi'] = $this->dbi;
$GLOBALS['cfg']['Import']['ldi_local_option'] = 'auto';
$this->object = new ImportLdi();
$properties = $this->object->getProperties();
@ -156,6 +154,10 @@ class ImportLdiTest extends PmaTestCase
global $sql_query, $sql_query_disabled;
$sql_query_disabled = false;
$this->dbi->expects($this->any())->method('escapeString')
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $this->dbi;
//Test function called
$this->object->doImport();
@ -215,6 +217,10 @@ class ImportLdiTest extends PmaTestCase
global $sql_query, $sql_query_disabled;
$sql_query_disabled = false;
$this->dbi->expects($this->any())->method('escapeString')
->will($this->returnArgument(0));
$GLOBALS['dbi'] = $this->dbi;
$ldi_local_option = true;
$ldi_replace = true;
$ldi_ignore = true;

View File

@ -23,13 +23,24 @@ class EventsTest extends TestCase
*
* @return void
*/
public function setUp()
protected function setUp()
{
$GLOBALS['tear_down']['server'] = false;
if (! isset($GLOBALS['cfg']['ServerDefault'])) {
$GLOBALS['cfg']['ServerDefault'] = '';
$GLOBALS['tear_down']['server'] = true;
}
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['AllowThirdPartyFraming'] = false;
$GLOBALS['cfg']['SendErrorReports'] = 'ask';
$GLOBALS['cfg']['DefaultTabDatabase'] = 'structure';
$GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true;
$GLOBALS['cfg']['DefaultTabTable'] = 'browse';
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = 'structure';
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'] = '';
$GLOBALS['cfg']['LimitChars'] = 50;
$GLOBALS['cfg']['Confirm'] = true;
$GLOBALS['cfg']['LoginCookieValidity'] = 1440;
$GLOBALS['cfg']['ServerDefault'] = '';
$GLOBALS['tear_down']['server'] = true;
}
/**

View File

@ -25,18 +25,29 @@ class RoutinesTest extends TestCase
*
* @return void
*/
public function setUp()
protected function setUp()
{
global $cfg;
$cfg['ShowFunctionFields'] = false;
$cfg['ServerDefault'] = 1;
$cfg['DefaultFunctions']['FUNC_NUMBER'] = '';
$cfg['DefaultFunctions']['FUNC_DATE'] = '';
$cfg['DefaultFunctions']['FUNC_SPATIAL'] = 'GeomFromText';
$GLOBALS['server'] = 0;
$GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath();
$GLOBALS['cfg']['ShowFunctionFields'] = false;
$GLOBALS['cfg']['ServerDefault'] = 1;
$GLOBALS['cfg']['DefaultFunctions']['FUNC_NUMBER'] = '';
$GLOBALS['cfg']['DefaultFunctions']['FUNC_DATE'] = '';
$GLOBALS['cfg']['DefaultFunctions']['FUNC_SPATIAL'] = 'GeomFromText';
$GLOBALS['cfg']['AllowThirdPartyFraming'] = false;
$GLOBALS['cfg']['SendErrorReports'] = 'ask';
$GLOBALS['cfg']['DefaultTabDatabase'] = 'structure';
$GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true;
$GLOBALS['cfg']['DefaultTabTable'] = 'browse';
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = 'structure';
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'] = '';
$GLOBALS['cfg']['LimitChars'] = 50;
$GLOBALS['cfg']['Confirm'] = true;
$GLOBALS['cfg']['LoginCookieValidity'] = 1440;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['server'] = 0;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath();
}
/**

View File

@ -23,11 +23,23 @@ class TriggersTest extends TestCase
*
* @return void
*/
public function setUp()
protected function setUp()
{
$GLOBALS['cfg']['ServerDefault'] = '';
$GLOBALS['cfg']['DBG']['sql'] = false;
$GLOBALS['cfg']['AllowThirdPartyFraming'] = false;
$GLOBALS['cfg']['SendErrorReports'] = 'ask';
$GLOBALS['cfg']['DefaultTabDatabase'] = 'structure';
$GLOBALS['cfg']['ShowDatabasesNavigationAsTree'] = true;
$GLOBALS['cfg']['DefaultTabTable'] = 'browse';
$GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = 'structure';
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2'] = '';
$GLOBALS['cfg']['LimitChars'] = 50;
$GLOBALS['cfg']['Confirm'] = true;
$GLOBALS['cfg']['LoginCookieValidity'] = 1440;
$GLOBALS['cfg']['NaturalOrder'] = false;
$GLOBALS['db'] = 'pma_test';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
}
/**

View File

@ -68,6 +68,7 @@ class PrivilegesTest extends TestCase
$GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF');
$GLOBALS['pmaThemeImage'] = 'image';
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['hostname'] = "hostname";
$GLOBALS['username'] = "username";
$GLOBALS['text_dir'] = "text_dir";

View File

@ -27,6 +27,7 @@ class UsersTest extends TestCase
public function testGetHtmlForSubMenusOnUsersPage()
{
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['ServerDefault'] = 1;
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$html = Users::getHtmlForSubMenusOnUsersPage('server_privileges.php');

View File

@ -25,6 +25,9 @@ class FormProcessingTest extends PmaTestCase
public function setUp()
{
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['ServerDefault'] = 1;
}