diff --git a/test/classes/Config/PageSettingsTest.php b/test/classes/Config/PageSettingsTest.php index e62758cba1..677336d323 100644 --- a/test/classes/Config/PageSettingsTest.php +++ b/test/classes/Config/PageSettingsTest.php @@ -28,6 +28,8 @@ class PageSettingsTest extends PmaTestCase $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['server'] = 1; $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = ''; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; } /** diff --git a/test/classes/Controllers/Database/DatabaseStructureControllerTest.php b/test/classes/Controllers/Database/DatabaseStructureControllerTest.php index 1c0ea424ad..7168e71550 100644 --- a/test/classes/Controllers/Database/DatabaseStructureControllerTest.php +++ b/test/classes/Controllers/Database/DatabaseStructureControllerTest.php @@ -46,6 +46,7 @@ class DatabaseStructureControllerTest extends PmaTestCase $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['table'] = "table"; $GLOBALS['db'] = 'db'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; //$_SESSION diff --git a/test/classes/Controllers/Server/ServerBinlogControllerTest.php b/test/classes/Controllers/Server/ServerBinlogControllerTest.php index 51cac44a0b..4593ddf82a 100644 --- a/test/classes/Controllers/Server/ServerBinlogControllerTest.php +++ b/test/classes/Controllers/Server/ServerBinlogControllerTest.php @@ -10,6 +10,7 @@ namespace PhpMyAdmin\Tests\Controllers\Server; use PhpMyAdmin\Controllers\Server\ServerBinlogController; use PhpMyAdmin\Di\Container; use PhpMyAdmin\Tests\PmaTestCase; +use PhpMyAdmin\Tests\Stubs\Response as ResponseStub; use PhpMyAdmin\Theme; use PhpMyAdmin\Util; use ReflectionClass; @@ -43,8 +44,10 @@ class ServerBinlogControllerTest extends PmaTestCase $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $GLOBALS['cfg']['LimitChars'] = 100; + $GLOBALS['db'] = 'db'; $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; //$_SESSION @@ -62,6 +65,9 @@ class ServerBinlogControllerTest extends PmaTestCase ->will($this->returnValue($binary_log_file_names)); $container = Container::getDefaultContainer(); $container->set('dbi', $dbi); + $this->_response = new ResponseStub(); + $container->set('PhpMyAdmin\Response', $this->_response); + $container->alias('response', 'PhpMyAdmin\Response'); } /** diff --git a/test/classes/Controllers/Server/ServerCollationsControllerTest.php b/test/classes/Controllers/Server/ServerCollationsControllerTest.php index 67450f6ba1..6550543158 100644 --- a/test/classes/Controllers/Server/ServerCollationsControllerTest.php +++ b/test/classes/Controllers/Server/ServerCollationsControllerTest.php @@ -11,25 +11,10 @@ use PhpMyAdmin\Controllers\Server\ServerCollationsController; use PhpMyAdmin\Core; use PhpMyAdmin\Di\Container; use PhpMyAdmin\Tests\PmaTestCase; +use PhpMyAdmin\Tests\Stubs\Response as ResponseStub; use PhpMyAdmin\Theme; use ReflectionClass; -/* - * Include to test. - */ -//$GLOBALS -$GLOBALS['server'] = 1; -$GLOBALS['cfg']['ServerDefault'] = 1; -$GLOBALS['url_query'] = "url_query"; -$GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); -$GLOBALS['lang'] = "en"; -$GLOBALS['text_dir'] = "text_dir"; -$GLOBALS['cfg']['Server'] = array( - 'DisableIS' => false -); - -require_once 'libraries/server_common.inc.php'; - /** * Tests for ServerCollationsController class * @@ -45,11 +30,14 @@ class ServerCollationsControllerTest extends PmaTestCase public function setUp() { //$_REQUEST - $_REQUEST['log'] = "index1"; + $_REQUEST['log'] = 'index1'; $_REQUEST['pos'] = 3; //$GLOBALS - $GLOBALS['table'] = "table"; + $GLOBALS['server'] = 1; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; } /** @@ -86,6 +74,8 @@ class ServerCollationsControllerTest extends PmaTestCase ); $container = Container::getDefaultContainer(); + $container->set('PhpMyAdmin\Response', new ResponseStub()); + $container->alias('response', 'PhpMyAdmin\Response'); $class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerCollationsController'); $method = $class->getMethod('_getHtmlForCharsets'); diff --git a/test/classes/Controllers/Server/ServerDatabasesControllerTest.php b/test/classes/Controllers/Server/ServerDatabasesControllerTest.php index 0fd1df1d09..8ff219ba60 100644 --- a/test/classes/Controllers/Server/ServerDatabasesControllerTest.php +++ b/test/classes/Controllers/Server/ServerDatabasesControllerTest.php @@ -19,7 +19,6 @@ use ReflectionClass; * * @package PhpMyAdmin-test */ - class ServerDatabasesControllerTest extends PmaTestCase { /** @@ -37,11 +36,14 @@ class ServerDatabasesControllerTest extends PmaTestCase $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); + $GLOBALS['db'] = 'db'; $GLOBALS['table'] = "table"; $GLOBALS['replication_info']['master']['status'] = false; $GLOBALS['replication_info']['slave']['status'] = false; $GLOBALS['pmaThemeImage'] = 'image'; $GLOBALS['text_dir'] = "text_dir"; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; + $GLOBALS['cfg']['Server']['DisableIS'] = false; //$_SESSION $GLOBALS['server'] = 1; diff --git a/test/classes/Controllers/Server/ServerEnginesControllerTest.php b/test/classes/Controllers/Server/ServerEnginesControllerTest.php index 2eba970468..80c27177a7 100644 --- a/test/classes/Controllers/Server/ServerEnginesControllerTest.php +++ b/test/classes/Controllers/Server/ServerEnginesControllerTest.php @@ -11,6 +11,7 @@ use PhpMyAdmin\Controllers\Server\ServerEnginesController; use PhpMyAdmin\Di\Container; use PhpMyAdmin\StorageEngine; use PhpMyAdmin\Tests\PmaTestCase; +use PhpMyAdmin\Tests\Stubs\Response as ResponseStub; use PhpMyAdmin\Theme; use PhpMyAdmin\Url; use PhpMyAdmin\Util; @@ -23,6 +24,11 @@ use ReflectionClass; */ class ServerEnginesControllerTest extends PmaTestCase { + /** + * @var \PhpMyAdmin\Di\Container + */ + private $container; + /** * Prepares environment for the test. * @@ -36,9 +42,13 @@ class ServerEnginesControllerTest extends PmaTestCase //$GLOBALS $GLOBALS['server'] = 0; - $GLOBALS['table'] = "table"; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; - //$_SESSION + $this->container = Container::getDefaultContainer(); + $this->container->set('PhpMyAdmin\Response', new ResponseStub()); + $this->container->alias('response', 'PhpMyAdmin\Response'); } /** @@ -52,11 +62,9 @@ class ServerEnginesControllerTest extends PmaTestCase $method = $class->getMethod('_getHtmlForAllServerEngines'); $method->setAccessible(true); - $container = Container::getDefaultContainer(); - $ctrl = new ServerEnginesController( - $container->get('response'), - $container->get('dbi') + $this->container->get('response'), + $this->container->get('dbi') ); $html = $method->invoke($ctrl); @@ -118,12 +126,10 @@ class ServerEnginesControllerTest extends PmaTestCase $method = $class->getMethod('_getHtmlForServerEngine'); $method->setAccessible(true); - $container = Container::getDefaultContainer(); - $engine_plugin = StorageEngine::getEngine("Pbxt"); $ctrl = new ServerEnginesController( - $container->get('response'), - $container->get('dbi') + $this->container->get('response'), + $this->container->get('dbi') ); $html = $method->invoke($ctrl, $engine_plugin); diff --git a/test/classes/Controllers/Server/ServerPluginsControllerTest.php b/test/classes/Controllers/Server/ServerPluginsControllerTest.php index 6774a1db5e..1592b98e6a 100644 --- a/test/classes/Controllers/Server/ServerPluginsControllerTest.php +++ b/test/classes/Controllers/Server/ServerPluginsControllerTest.php @@ -10,6 +10,7 @@ namespace PhpMyAdmin\Tests\Controllers\Server; use PhpMyAdmin\Controllers\Server\ServerPluginsController; use PhpMyAdmin\Di\Container; use PhpMyAdmin\Tests\PmaTestCase; +use PhpMyAdmin\Tests\Stubs\Response as ResponseStub; use PhpMyAdmin\Theme; use ReflectionClass; @@ -32,9 +33,10 @@ class ServerPluginsControllerTest extends PmaTestCase $_REQUEST['pos'] = 3; //$GLOBALS - $GLOBALS['table'] = "table"; - - //$_SESSION + $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; } /** @@ -75,6 +77,8 @@ class ServerPluginsControllerTest extends PmaTestCase ->will($this->returnValue(true)); $container = Container::getDefaultContainer(); + $container->set('PhpMyAdmin\Response', new ResponseStub()); + $container->alias('response', 'PhpMyAdmin\Response'); $container->set('dbi', $dbi); $class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerPluginsController'); diff --git a/test/classes/Controllers/Server/ServerVariablesControllerTest.php b/test/classes/Controllers/Server/ServerVariablesControllerTest.php index 93824c53e8..776b2a81f4 100644 --- a/test/classes/Controllers/Server/ServerVariablesControllerTest.php +++ b/test/classes/Controllers/Server/ServerVariablesControllerTest.php @@ -42,7 +42,8 @@ class ServerVariablesControllerTest extends PmaTestCase //$GLOBALS $GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); $GLOBALS['server'] = 1; - $GLOBALS['table'] = "table"; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; //$_SESSION diff --git a/test/classes/Controllers/Table/TableIndexesControllerTest.php b/test/classes/Controllers/Table/TableIndexesControllerTest.php index b17ec0a495..5a22baf45a 100644 --- a/test/classes/Controllers/Table/TableIndexesControllerTest.php +++ b/test/classes/Controllers/Table/TableIndexesControllerTest.php @@ -36,12 +36,14 @@ class TableIndexesControllerTest extends PmaTestCase * SET these to avoid undefined index error */ $GLOBALS['server'] = 1; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $GLOBALS['cfg']['Server']['pmadb'] = ''; $GLOBALS['url_params'] = array( 'db' => 'db', 'server' => 1 ); - $GLOBALS['db'] = 'db'; $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() diff --git a/test/classes/Controllers/Table/TableRelationControllerTest.php b/test/classes/Controllers/Table/TableRelationControllerTest.php index 06fa62cd8d..bea6c91deb 100644 --- a/test/classes/Controllers/Table/TableRelationControllerTest.php +++ b/test/classes/Controllers/Table/TableRelationControllerTest.php @@ -31,6 +31,9 @@ class TableRelationControllerTest extends PmaTestCase protected function setUp() { $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; //$_SESSION $_REQUEST['foreignDb'] = 'db'; @@ -39,9 +42,28 @@ class TableRelationControllerTest extends PmaTestCase $GLOBALS['dblist'] = new DataBasePMAMockForTblRelation(); $GLOBALS['dblist']->databases = new DataBaseMockForTblRelation(); + $indexes = array( + array( + 'Schema' => 'Schema1', + 'Key_name' => 'Key_name1', + 'Column_name' => 'Column_name1', + ), + array( + 'Schema' => 'Schema2', + 'Key_name' => 'Key_name2', + 'Column_name' => 'Column_name2', + ), + array( + 'Schema' => 'Schema3', + 'Key_name' => 'Key_name3', + 'Column_name' => 'Column_name3', + ), + ); $dbi = $this->getMockBuilder('PhpMyAdmin\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); + $dbi->expects($this->any())->method('getTableIndexes') + ->will($this->returnValue($indexes)); $GLOBALS['dbi'] = $dbi; diff --git a/test/classes/Controllers/Table/TableSearchControllerTest.php b/test/classes/Controllers/Table/TableSearchControllerTest.php index d5531790f4..4bb73f6efc 100644 --- a/test/classes/Controllers/Table/TableSearchControllerTest.php +++ b/test/classes/Controllers/Table/TableSearchControllerTest.php @@ -42,6 +42,8 @@ class TableSearchControllerTest extends PmaTestCase $_POST['zoom_submit'] = 'zoom'; $GLOBALS['server'] = 1; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $GLOBALS['cfgRelation'] = Relation::getRelationsParam(); $GLOBALS['cfg']['Server']['DisableIS'] = false; diff --git a/test/classes/Controllers/Table/TableStructureControllerTest.php b/test/classes/Controllers/Table/TableStructureControllerTest.php index b030189d00..e721ed220d 100644 --- a/test/classes/Controllers/Table/TableStructureControllerTest.php +++ b/test/classes/Controllers/Table/TableStructureControllerTest.php @@ -42,11 +42,10 @@ class TableStructureControllerTest extends PmaTestCase //$GLOBALS $GLOBALS['server'] = 1; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; $GLOBALS['cfg']['Server']['DisableIS'] = false; - - $GLOBALS['table'] = "table"; - - //$_SESSION + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $table = $this->getMockBuilder('PhpMyAdmin\Table') ->disableOriginalConstructor() diff --git a/test/classes/Display/ExportTest.php b/test/classes/Display/ExportTest.php index de82edbe0f..e98684dd04 100644 --- a/test/classes/Display/ExportTest.php +++ b/test/classes/Display/ExportTest.php @@ -48,6 +48,7 @@ class ExportTest extends TestCase $GLOBALS['cfg']['BZipDump'] = false; $GLOBALS['cfg']['Export']['asfile'] = true; $GLOBALS['cfg']['Export']['file_template_server'] = "file_template_server"; + $GLOBALS['cfg']['AvailableCharsets'] = []; $GLOBALS['PMA_PHP_SELF'] = Core::getenv('PHP_SELF'); $GLOBALS['PMA_recoding_engine'] = "InnerDB"; $GLOBALS['server'] = 0; diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index fed7bdb676..ef2a4fed11 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -39,6 +39,9 @@ class ResultsTest extends PmaTestCase protected function setUp() { $GLOBALS['server'] = 0; + $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; $this->object = new DisplayResults('as', '', '', ''); $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Config']->enableBc(); diff --git a/test/classes/Gis/GisGeomTest.php b/test/classes/Gis/GisGeomTestCase.php similarity index 89% rename from test/classes/Gis/GisGeomTest.php rename to test/classes/Gis/GisGeomTestCase.php index 27d97014f0..2addb4e1f3 100644 --- a/test/classes/Gis/GisGeomTest.php +++ b/test/classes/Gis/GisGeomTestCase.php @@ -1,7 +1,7 @@ test classes + * Abstract parent class for all Gis test classes * * @package PhpMyAdmin-test */ @@ -10,13 +10,12 @@ namespace PhpMyAdmin\Tests\Gis; use PHPUnit\Framework\TestCase; /** - * Abstract parent class for all GIS test classes + * Abstract parent class for all Gis test classes * * @package PhpMyAdmin-test */ -abstract class GisGeomTest extends TestCase +abstract class GisGeomTestCase extends TestCase { - /** * test generateParams method * diff --git a/test/classes/Gis/GisLineStringTest.php b/test/classes/Gis/GisLineStringTest.php index 59cfdc0db7..d438248d4e 100644 --- a/test/classes/Gis/GisLineStringTest.php +++ b/test/classes/Gis/GisLineStringTest.php @@ -8,7 +8,7 @@ namespace PhpMyAdmin\Tests\Gis; use PhpMyAdmin\Gis\GisLineString; -use PhpMyAdmin\Tests\Gis\GisGeomTest; +use PhpMyAdmin\Tests\Gis\GisGeomTestCase; use TCPDF; /** @@ -16,7 +16,7 @@ use TCPDF; * * @package PhpMyAdmin-test */ -class GisLineStringTest extends GisGeomTest +class GisLineStringTest extends GisGeomTestCase { /** * @var GisLineString diff --git a/test/classes/Gis/GisMultiLineStringTest.php b/test/classes/Gis/GisMultiLineStringTest.php index b37594bf1d..9120b6bc0e 100644 --- a/test/classes/Gis/GisMultiLineStringTest.php +++ b/test/classes/Gis/GisMultiLineStringTest.php @@ -8,7 +8,7 @@ namespace PhpMyAdmin\Tests\Gis; use PhpMyAdmin\Gis\GisMultiLineString; -use PhpMyAdmin\Tests\Gis\GisGeomTest; +use PhpMyAdmin\Tests\Gis\GisGeomTestCase; use TCPDF; /** @@ -16,7 +16,7 @@ use TCPDF; * * @package PhpMyAdmin-test */ -class GisMultiLineStringTest extends GisGeomTest +class GisMultiLineStringTest extends GisGeomTestCase { /** * @var GisMultiLineString diff --git a/test/classes/Gis/GisMultiPointTest.php b/test/classes/Gis/GisMultiPointTest.php index 3ac100e2a4..6fd86ebab8 100644 --- a/test/classes/Gis/GisMultiPointTest.php +++ b/test/classes/Gis/GisMultiPointTest.php @@ -8,7 +8,7 @@ namespace PhpMyAdmin\Tests\Gis; use PhpMyAdmin\Gis\GisMultiPoint; -use PhpMyAdmin\Tests\Gis\GisGeomTest; +use PhpMyAdmin\Tests\Gis\GisGeomTestCase; use TCPDF; /** @@ -16,7 +16,7 @@ use TCPDF; * * @package PhpMyAdmin-test */ -class GisMultiPointTest extends GisGeomTest +class GisMultiPointTest extends GisGeomTestCase { /** * @var GisMultiPoint diff --git a/test/classes/Gis/GisMultiPolygonTest.php b/test/classes/Gis/GisMultiPolygonTest.php index a346a55686..cf50ad8581 100644 --- a/test/classes/Gis/GisMultiPolygonTest.php +++ b/test/classes/Gis/GisMultiPolygonTest.php @@ -8,7 +8,7 @@ namespace PhpMyAdmin\Tests\Gis; use PhpMyAdmin\Gis\GisMultiPolygon; -use PhpMyAdmin\Tests\Gis\GisGeomTest; +use PhpMyAdmin\Tests\Gis\GisGeomTestCase; use TCPDF; /** @@ -16,7 +16,7 @@ use TCPDF; * * @package PhpMyAdmin-test */ -class GisMultiPolygonTest extends GisGeomTest +class GisMultiPolygonTest extends GisGeomTestCase { /** * @var GisMultiPolygon diff --git a/test/classes/Gis/GisPointTest.php b/test/classes/Gis/GisPointTest.php index cf321458ac..c2f71cb8ad 100644 --- a/test/classes/Gis/GisPointTest.php +++ b/test/classes/Gis/GisPointTest.php @@ -8,7 +8,7 @@ namespace PhpMyAdmin\Tests\Gis; use PhpMyAdmin\Gis\GisPoint; -use PhpMyAdmin\Tests\Gis\GisGeomTest; +use PhpMyAdmin\Tests\Gis\GisGeomTestCase; use TCPDF; /** @@ -16,7 +16,7 @@ use TCPDF; * * @package PhpMyAdmin-test */ -class GisPointTest extends GisGeomTest +class GisPointTest extends GisGeomTestCase { /** * @var GisPoint diff --git a/test/classes/Gis/GisPolygonTest.php b/test/classes/Gis/GisPolygonTest.php index 6f55e514f4..5dc0921f0c 100644 --- a/test/classes/Gis/GisPolygonTest.php +++ b/test/classes/Gis/GisPolygonTest.php @@ -8,7 +8,7 @@ namespace PhpMyAdmin\Tests\Gis; use PhpMyAdmin\Gis\GisPolygon; -use PhpMyAdmin\Tests\Gis\GisGeomTest; +use PhpMyAdmin\Tests\Gis\GisGeomTestCase; use TCPDF; /** @@ -16,7 +16,7 @@ use TCPDF; * * @package PhpMyAdmin-test */ -class GisPolygonTest extends GisGeomTest +class GisPolygonTest extends GisGeomTestCase { /** * @var GisPolygon diff --git a/test/classes/Plugins/Export/ExportLatexTest.php b/test/classes/Plugins/Export/ExportLatexTest.php index c9cf9797c1..ba6649fa84 100644 --- a/test/classes/Plugins/Export/ExportLatexTest.php +++ b/test/classes/Plugins/Export/ExportLatexTest.php @@ -40,6 +40,7 @@ class ExportLatexTest extends PmaTestCase $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfgRelation']['relation'] = true; $GLOBALS['db'] = 'db'; + $GLOBALS['table'] = 'table'; $this->object = new ExportLatex(); } diff --git a/test/classes/Server/UsersTest.php b/test/classes/Server/UsersTest.php index d939b2690f..a1954fef38 100644 --- a/test/classes/Server/UsersTest.php +++ b/test/classes/Server/UsersTest.php @@ -27,6 +27,7 @@ class UsersTest extends TestCase public function testGetHtmlForSubMenusOnUsersPage() { $GLOBALS['server'] = 1; + $GLOBALS['cfg']['Server']['DisableIS'] = false; $html = Users::getHtmlForSubMenusOnUsersPage('server_privileges.php'); //validate 1: topmenu2