diff --git a/composer.json b/composer.json index c8db71e803..6572b3c6ae 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "autoload-dev": { "psr-4": { "PhpMyAdmin\\Tests\\": "test/classes" - } + }, + "classmap": ["test/PMATestCase.php"] }, "repositories": [ { diff --git a/test/classes/AdvisorTest.php b/test/classes/AdvisorTest.php index 2c35421034..f1e5e57af8 100644 --- a/test/classes/AdvisorTest.php +++ b/test/classes/AdvisorTest.php @@ -5,13 +5,10 @@ * * @package PhpMyAdmin-test */ - -/* - * Include to test. - */ -require_once 'test/PMATestCase.php'; +namespace PhpMyAdmin\Tests; use PhpMyAdmin\Advisor; +use PhpMyAdmin\Config; use PhpMyAdmin\Theme; /** @@ -19,7 +16,7 @@ use PhpMyAdmin\Theme; * * @package PhpMyAdmin-test */ -class AdvisorTest extends PMATestCase +class AdvisorTest extends \PMATestCase { /** @@ -30,6 +27,7 @@ class AdvisorTest extends PMATestCase */ public function setup() { + $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['server'] = 1; } diff --git a/test/classes/BookmarkTest.php b/test/classes/BookmarkTest.php index 8eece388ed..17b8e336c0 100644 --- a/test/classes/BookmarkTest.php +++ b/test/classes/BookmarkTest.php @@ -5,15 +5,17 @@ * * @package PhpMyAdmin-test */ -use PhpMyAdmin\Bookmark; +namespace PhpMyAdmin\Tests; +use PhpMyAdmin\Bookmark; +use PHPUnit_Framework_TestCase as TestCase; /** * Tests for Bookmark class * * @package PhpMyAdmin-test */ -class BookmarkTest extends PHPUnit_Framework_TestCase +class BookmarkTest extends TestCase { /** * Sets up the fixture, for example, opens a network connection. diff --git a/test/classes/BrowseForeignersTest.php b/test/classes/BrowseForeignersTest.php index 999adada4e..e62c2dd2fa 100644 --- a/test/classes/BrowseForeignersTest.php +++ b/test/classes/BrowseForeignersTest.php @@ -8,13 +8,14 @@ namespace PhpMyAdmin\Tests; use PhpMyAdmin\BrowseForeigners; +use PHPUnit_Framework_TestCase as TestCase; /** * Tests for PhpMyAdmin\BrowseForeigners * * @package PhpMyAdmin-test */ -class BrowseForeignersTest extends \PHPUnit_Framework_TestCase +class BrowseForeignersTest extends TestCase { /** * Setup for test cases diff --git a/test/classes/CentralColumnsTest.php b/test/classes/CentralColumnsTest.php index 7b4c740e91..47395ac283 100644 --- a/test/classes/CentralColumnsTest.php +++ b/test/classes/CentralColumnsTest.php @@ -8,20 +8,21 @@ namespace PhpMyAdmin\Tests; use PhpMyAdmin\CentralColumns; +use PhpMyAdmin\Config; use PhpMyAdmin\Theme; use PhpMyAdmin\TypesMySQL; use PhpMyAdmin\Url; use PhpMyAdmin\Util; +use PHPUnit_Framework_TestCase as TestCase; $GLOBALS['server'] = 1; - /** * tests for PhpMyAdmin\CentralColumns * * @package PhpMyAdmin-test */ -class CentralColumnsTest extends \PHPUnit_Framework_TestCase +class CentralColumnsTest extends TestCase { private $_columnData = array( array( @@ -67,6 +68,7 @@ class CentralColumnsTest extends \PHPUnit_Framework_TestCase */ public function setUp() { + $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['PMA_Types'] = new TypesMySQL(); $GLOBALS['cfg']['Server']['user'] = 'pma_user'; $GLOBALS['cfg']['Server']['DisableIS'] = true; diff --git a/test/classes/CharsetsTest.php b/test/classes/CharsetsTest.php index ea0036dfca..1d9bf56ef3 100644 --- a/test/classes/CharsetsTest.php +++ b/test/classes/CharsetsTest.php @@ -5,15 +5,17 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests; use PhpMyAdmin\Charsets; +use PHPUnit_Framework_TestCase as TestCase; /** * Tests for MySQL Charsets * * @package PhpMyAdmin-test */ -class CharsetsTest extends PHPUnit_Framework_TestCase +class CharsetsTest extends TestCase { public function setUp() { diff --git a/test/classes/CheckUserPrivilegesTest.php b/test/classes/CheckUserPrivilegesTest.php index d7bc41cbfb..00e98af5fe 100644 --- a/test/classes/CheckUserPrivilegesTest.php +++ b/test/classes/CheckUserPrivilegesTest.php @@ -8,6 +8,7 @@ namespace PhpMyAdmin\Tests; use PhpMyAdmin\CheckUserPrivileges; +use PHPUnit_Framework_TestCase as TestCase; /* * Include to test. @@ -20,7 +21,7 @@ $GLOBALS['cfg']['Server']['DisableIS'] = false; * * @package PhpMyAdmin-test */ -class CheckUserPrivilegesTest extends \PHPUnit_Framework_TestCase +class CheckUserPrivilegesTest extends TestCase { /** * prepares environment for tests diff --git a/test/classes/config/ConfigFileTest.php b/test/classes/Config/ConfigFileTest.php similarity index 99% rename from test/classes/config/ConfigFileTest.php rename to test/classes/Config/ConfigFileTest.php index f86c3e6f64..1c161e7df7 100644 --- a/test/classes/config/ConfigFileTest.php +++ b/test/classes/Config/ConfigFileTest.php @@ -5,20 +5,17 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests\Config; -/* - * Include to test. - */ use PhpMyAdmin\Config\ConfigFile; - -require_once 'test/PMATestCase.php'; +use stdClass; /** * Tests for Config File Management * * @package PhpMyAdmin-test */ -class ConfigFileTest extends PMATestCase +class ConfigFileTest extends \PMATestCase { /** * Any valid key that exists in config.default.php and isn't empty diff --git a/test/classes/config/DescriptionTest.php b/test/classes/Config/DescriptionTest.php similarity index 90% rename from test/classes/config/DescriptionTest.php rename to test/classes/Config/DescriptionTest.php index 16252e0c9f..9c2d660c84 100644 --- a/test/classes/config/DescriptionTest.php +++ b/test/classes/Config/DescriptionTest.php @@ -5,18 +5,28 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests\Config; +use PhpMyAdmin\Config; use PhpMyAdmin\Config\Descriptions; -require_once 'test/PMATestCase.php'; - /** * Tests for PMA_FormDisplay class * * @package PhpMyAdmin-test */ -class DescriptionTest extends PMATestCase +class DescriptionTest extends \PMATestCase { + /** + * Setup tests + * + * @return void + */ + public function setUp() + { + $GLOBALS['PMA_Config'] = new Config(); + } + /** * @dataProvider getValues */ diff --git a/test/classes/config/FormDisplayTemplateTest.php b/test/classes/Config/FormDisplayTemplateTest.php similarity index 98% rename from test/classes/config/FormDisplayTemplateTest.php rename to test/classes/Config/FormDisplayTemplateTest.php index 6129298d69..d8428b09ec 100644 --- a/test/classes/config/FormDisplayTemplateTest.php +++ b/test/classes/Config/FormDisplayTemplateTest.php @@ -5,7 +5,9 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests\Config; +use PhpMyAdmin\Config; use PhpMyAdmin\Config\FormDisplayTemplate; use PhpMyAdmin\Theme; use PHPUnit_Framework_TestCase as TestCase; @@ -17,6 +19,16 @@ use PHPUnit_Framework_TestCase as TestCase; */ class FormDisplayTemplateTest extends TestCase { + /** + * Setup tests + * + * @return void + */ + public function setUp() + { + $GLOBALS['PMA_Config'] = new Config(); + } + /** * Test for FormDisplayTemplate::displayFormTop() * diff --git a/test/classes/config/FormDisplayTest.php b/test/classes/Config/FormDisplayTest.php similarity index 93% rename from test/classes/config/FormDisplayTest.php rename to test/classes/Config/FormDisplayTest.php index 05036722c3..259eb70858 100644 --- a/test/classes/config/FormDisplayTest.php +++ b/test/classes/Config/FormDisplayTest.php @@ -5,19 +5,21 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests\Config; use PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\FormDisplay; - -require_once 'test/PMATestCase.php'; +use ReflectionClass; +use ReflectionMethod; +use ReflectionProperty; /** * Tests for PMA_FormDisplay class * * @package PhpMyAdmin-test */ -class FormDisplayTest extends PMATestCase +class FormDisplayTest extends \PMATestCase { /** * @var FormDisplay @@ -33,7 +35,6 @@ class FormDisplayTest extends PMATestCase { $GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath(); $GLOBALS['PMA_Config'] = new Config(); - $GLOBALS['PMA_Config']->enableBc(); $GLOBALS['server'] = 0; $this->object = new FormDisplay(new ConfigFile()); } @@ -70,7 +71,7 @@ class FormDisplayTest extends PMATestCase */ public function testRegisterForm() { - $reflection = new \ReflectionClass('PhpMyAdmin\Config\FormDisplay'); + $reflection = new ReflectionClass('PhpMyAdmin\Config\FormDisplay'); $attrForms = $reflection->getProperty('_forms'); $attrForms->setAccessible(true); @@ -125,7 +126,7 @@ class FormDisplayTest extends PMATestCase ->setMethods(array('save')) ->getMock(); - $attrForms = new \ReflectionProperty('PhpMyAdmin\Config\FormDisplay', '_forms'); + $attrForms = new ReflectionProperty('PhpMyAdmin\Config\FormDisplay', '_forms'); $attrForms->setAccessible(true); $attrForms->setValue($this->object, array(1, 2, 3)); @@ -152,7 +153,7 @@ class FormDisplayTest extends PMATestCase */ public function testDisplayErrors() { - $reflection = new \ReflectionClass('PhpMyAdmin\Config\FormDisplay'); + $reflection = new ReflectionClass('PhpMyAdmin\Config\FormDisplay'); $attrIsValidated = $reflection->getProperty('_isValidated'); $attrIsValidated->setAccessible(true); @@ -198,7 +199,7 @@ class FormDisplayTest extends PMATestCase */ public function testFixErrors() { - $reflection = new \ReflectionClass('PhpMyAdmin\Config\FormDisplay'); + $reflection = new ReflectionClass('PhpMyAdmin\Config\FormDisplay'); $attrIsValidated = $reflection->getProperty('_isValidated'); $attrIsValidated->setAccessible(true); @@ -249,7 +250,7 @@ class FormDisplayTest extends PMATestCase */ public function testValidateSelect() { - $attrValidateSelect = new \ReflectionMethod( + $attrValidateSelect = new ReflectionMethod( 'PhpMyAdmin\Config\FormDisplay', '_validateSelect' ); @@ -303,7 +304,7 @@ class FormDisplayTest extends PMATestCase */ public function testHasErrors() { - $attrErrors = new \ReflectionProperty('PhpMyAdmin\Config\FormDisplay', '_errors'); + $attrErrors = new ReflectionProperty('PhpMyAdmin\Config\FormDisplay', '_errors'); $attrErrors->setAccessible(true); $this->assertFalse( @@ -351,7 +352,7 @@ class FormDisplayTest extends PMATestCase */ public function testGetOptName() { - $method = new \ReflectionMethod('PhpMyAdmin\Config\FormDisplay', '_getOptName'); + $method = new ReflectionMethod('PhpMyAdmin\Config\FormDisplay', '_getOptName'); $method->setAccessible(true); $this->assertEquals( @@ -372,10 +373,10 @@ class FormDisplayTest extends PMATestCase */ public function testLoadUserprefsInfo() { - $method = new \ReflectionMethod('PhpMyAdmin\Config\FormDisplay', '_loadUserprefsInfo'); + $method = new ReflectionMethod('PhpMyAdmin\Config\FormDisplay', '_loadUserprefsInfo'); $method->setAccessible(true); - $attrUserprefs = new \ReflectionProperty( + $attrUserprefs = new ReflectionProperty( 'PhpMyAdmin\Config\FormDisplay', '_userprefsDisallow' ); @@ -395,7 +396,7 @@ class FormDisplayTest extends PMATestCase */ public function testSetComments() { - $method = new \ReflectionMethod('PhpMyAdmin\Config\FormDisplay', '_setComments'); + $method = new ReflectionMethod('PhpMyAdmin\Config\FormDisplay', '_setComments'); $method->setAccessible(true); // recoding diff --git a/test/classes/config/FormTest.php b/test/classes/Config/FormTest.php similarity index 93% rename from test/classes/config/FormTest.php rename to test/classes/Config/FormTest.php index 06635c5943..273abffbe7 100644 --- a/test/classes/config/FormTest.php +++ b/test/classes/Config/FormTest.php @@ -5,20 +5,21 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests\Config; use PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\Form; use PhpMyAdmin\Theme; - -require_once 'test/PMATestCase.php'; +use ReflectionClass; +use ReflectionProperty; /** * Tests for PMA_Form class * * @package PhpMyAdmin-test */ -class FormTest extends PMATestCase +class FormTest extends \PMATestCase { /** * @var Form @@ -34,7 +35,6 @@ class FormTest extends PMATestCase { $GLOBALS['pmaThemePath'] = $GLOBALS['PMA_Theme']->getPath(); $GLOBALS['PMA_Config'] = new Config(); - $GLOBALS['PMA_Config']->enableBc(); $GLOBALS['server'] = 0; $this->object = new Form( 'pma_form_name', array('pma_form1','pma_form2'), new ConfigFile(), 1 @@ -80,7 +80,7 @@ class FormTest extends PMATestCase */ public function testGetOptionType() { - $attrFieldsTypes = new \ReflectionProperty('PhpMyAdmin\Config\Form', '_fieldsTypes'); + $attrFieldsTypes = new ReflectionProperty('PhpMyAdmin\Config\Form', '_fieldsTypes'); $attrFieldsTypes->setAccessible(true); $attrFieldsTypes->setValue( $this->object, @@ -136,7 +136,7 @@ class FormTest extends PMATestCase */ public function testReadFormPathsCallBack() { - $reflection = new \ReflectionClass('PhpMyAdmin\Config\Form'); + $reflection = new ReflectionClass('PhpMyAdmin\Config\Form'); $method = $reflection->getMethod('_readFormPathsCallback'); $method->setAccessible(true); @@ -188,7 +188,7 @@ class FormTest extends PMATestCase */ public function testReadFormPaths() { - $reflection = new \ReflectionClass('PhpMyAdmin\Config\Form'); + $reflection = new ReflectionClass('PhpMyAdmin\Config\Form'); $method = $reflection->getMethod('readFormPaths'); $method->setAccessible(true); @@ -243,7 +243,7 @@ class FormTest extends PMATestCase */ public function testReadTypes() { - $reflection = new \ReflectionClass('PhpMyAdmin\Config\Form'); + $reflection = new ReflectionClass('PhpMyAdmin\Config\Form'); $method = $reflection->getMethod('readTypes'); $method->setAccessible(true); diff --git a/test/classes/config/FormListTest.php b/test/classes/Config/Forms/FormListTest.php similarity index 93% rename from test/classes/config/FormListTest.php rename to test/classes/Config/Forms/FormListTest.php index 11a82d4321..ab0e02e467 100644 --- a/test/classes/config/FormListTest.php +++ b/test/classes/Config/Forms/FormListTest.php @@ -5,23 +5,24 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests\Config\Forms; +use PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\Forms\User\UserFormList; use PhpMyAdmin\Config\Forms\Page\PageFormList; use PhpMyAdmin\Config\Forms\Setup\SetupFormList; -require_once 'test/PMATestCase.php'; - /** * Tests for PMA_FormDisplay class * * @package PhpMyAdmin-test */ -class FormListTest extends PMATestCase +class FormListTest extends \PMATestCase { public function setUp() { + $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['server'] = 1; } diff --git a/test/classes/config/PageSettingsTest.php b/test/classes/Config/PageSettingsTest.php similarity index 93% rename from test/classes/config/PageSettingsTest.php rename to test/classes/Config/PageSettingsTest.php index ba7367e72d..dc7526240a 100644 --- a/test/classes/config/PageSettingsTest.php +++ b/test/classes/Config/PageSettingsTest.php @@ -5,16 +5,17 @@ * * @package PhpMyAdmin-test */ -use PhpMyAdmin\Config\PageSettings; +namespace PhpMyAdmin\Tests\Config; -require_once 'test/PMATestCase.php'; +use PhpMyAdmin\Config; +use PhpMyAdmin\Config\PageSettings; /** * Tests for PhpMyAdmin\Config\PageSettings * * @package PhpMyAdmin-test */ -class PageSettingsTest extends PMATestCase +class PageSettingsTest extends \PMATestCase { /** * Setup tests @@ -23,6 +24,7 @@ class PageSettingsTest extends PMATestCase */ public function setUp() { + $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['server'] = 1; $GLOBALS['db'] = 'db'; } diff --git a/test/classes/config/ServerConfigChecksTest.php b/test/classes/Config/ServerConfigChecksTest.php similarity index 94% rename from test/classes/config/ServerConfigChecksTest.php rename to test/classes/Config/ServerConfigChecksTest.php index 7441c6a9dd..3599418189 100644 --- a/test/classes/config/ServerConfigChecksTest.php +++ b/test/classes/Config/ServerConfigChecksTest.php @@ -5,23 +5,25 @@ * * @package PhpMyAdmin-test */ +namespace PhpMyAdmin\Tests\Config; +use PhpMyAdmin\Config; use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\Config\ServerConfigChecks; - -require_once 'test/PMATestCase.php'; +use ReflectionProperty; /** * Tests for ServeConfigChecks class * * @package PhpMyAdmin-test */ -class ServeConfigChecksTest extends PMATestCase +class ServeConfigChecksTest extends \PMATestCase { private $sessionID; public function setUp() { + $GLOBALS['PMA_Config'] = new Config(); $GLOBALS['cfg']['AvailableCharsets'] = array(); $GLOBALS['cfg']['ServerDefault'] = 0; $GLOBALS['server'] = 0; @@ -29,7 +31,7 @@ class ServeConfigChecksTest extends PMATestCase $cf = new ConfigFile(); $GLOBALS['ConfigFile'] = $cf; - $reflection = new \ReflectionProperty('PhpMyAdmin\Config\ConfigFile', '_id'); + $reflection = new ReflectionProperty('PhpMyAdmin\Config\ConfigFile', '_id'); $reflection->setAccessible(true); $this->sessionID = $reflection->getValue($cf); diff --git a/test/classes/ConfigTest.php b/test/classes/ConfigTest.php index b77f117c7e..02ebc94189 100644 --- a/test/classes/ConfigTest.php +++ b/test/classes/ConfigTest.php @@ -6,20 +6,18 @@ * @package PhpMyAdmin-test * @group current */ +namespace PhpMyAdmin\Tests; -/* - * Include to test. - */ +use PhpMyAdmin\Config; use PhpMyAdmin\Theme; - -require_once 'test/PMATestCase.php'; +use PHPUnit_Framework_Assert as Assert; /** * Tests behaviour of PhpMyAdmin\Config class * * @package PhpMyAdmin-test */ -class ConfigTest extends PMATestCase +class ConfigTest extends \PMATestCase { /** * Turn off backup globals @@ -44,14 +42,14 @@ class ConfigTest extends PMATestCase */ protected function setUp() { - $this->object = new PhpMyAdmin\Config; + $this->object = new Config; $GLOBALS['server'] = 0; $_SESSION['is_git_revision'] = true; - $GLOBALS['PMA_Config'] = new PhpMyAdmin\Config(CONFIG_FILE); + $GLOBALS['PMA_Config'] = new Config(CONFIG_FILE); $GLOBALS['cfg']['ProxyUrl'] = ''; //for testing file permissions - $this->permTestObj = new PhpMyAdmin\Config("./config.sample.inc.php"); + $this->permTestObj = new Config("./config.sample.inc.php"); } /** @@ -90,12 +88,12 @@ class ConfigTest extends PMATestCase { $this->assertContains( '
assertContains( '