Merge remote-tracking branch 'yasitha/master'
This commit is contained in:
commit
c653febf2f
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for displaing results
|
||||
* Tests for Error.class.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
@ -11,12 +11,30 @@
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/List_Database.class.php';
|
||||
require_once 'libraries/relation.lib.php';
|
||||
|
||||
class PMA_List_Database_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$GLOBALS['cfg']['Server']['only_db'] = array('single\\_db');
|
||||
$this->object = $this->getMockForAbstractClass('PMA_List_Database');
|
||||
}
|
||||
|
||||
/**
|
||||
* Call protected functions by making the visibitlity to public.
|
||||
*
|
||||
* @param string $name method name
|
||||
* @param array $params parameters for the invocation
|
||||
*
|
||||
* @return the output from the protected method.
|
||||
*/
|
||||
private function _callProtectedFunction($name, $params)
|
||||
{
|
||||
$class = new ReflectionClass('PMA_List_Database');
|
||||
$method = $class->getMethod($name);
|
||||
$method->setAccessible(true);
|
||||
return $method->invokeArgs($this->object, $params);
|
||||
}
|
||||
|
||||
public function testEmpty()
|
||||
@ -54,5 +72,73 @@ class PMA_List_Database_test extends PHPUnit_Framework_TestCase
|
||||
$arr = new PMA_List_Database;
|
||||
$this->assertEquals('<option value="single_db">single_db</option>' . "\n", $arr->getHtmlOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for checkHideDatabase
|
||||
*/
|
||||
public function testCheckHideDatabase()
|
||||
{
|
||||
$GLOBALS['cfg']['Server']['hide_db'] = array('single\\_db');
|
||||
$this->assertEquals(
|
||||
$this->_callProtectedFunction(
|
||||
'checkHideDatabase',
|
||||
array()
|
||||
),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getDefault
|
||||
*/
|
||||
public function testGetDefault()
|
||||
{
|
||||
$GLOBALS['db'] = '';
|
||||
$this->assertEquals(
|
||||
$this->object->getDefault(),
|
||||
''
|
||||
);
|
||||
|
||||
$GLOBALS['db'] = 'mysql';
|
||||
$this->assertEquals(
|
||||
$this->object->getDefault(),
|
||||
'mysql'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getGroupedDetails
|
||||
*/
|
||||
public function testGetGroupedDetails()
|
||||
{
|
||||
$GLOBALS['cfg']['ShowTooltip'] = true;
|
||||
$GLOBALS['cfgRelation']['commwork'] = true;
|
||||
$GLOBALS['server'] = 1;
|
||||
$GLOBALS['cfg']['LeftFrameDBTree'] = true;
|
||||
$GLOBALS['cfg']['LeftFrameDBSeparator'] = array('|',',');
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getGroupedDetails(10, 100),
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getHtmlListGrouped
|
||||
*/
|
||||
public function testGetHtmlListGrouped()
|
||||
{
|
||||
$GLOBALS['cfg']['ShowTooltip'] = true;
|
||||
$GLOBALS['cfgRelation']['commwork'] = true;
|
||||
$GLOBALS['server'] = 1;
|
||||
$GLOBALS['cfg']['LeftFrameDBTree'] = true;
|
||||
$GLOBALS['cfg']['LeftFrameDBSeparator'] = array('|',',');
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getHtmlListGrouped(true,5,5),
|
||||
'<ul id="databaseList" lang="en" dir="ltr">
|
||||
</ul>'
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
137
test/classes/PMA_Scripts_test.php
Normal file
137
test/classes/PMA_Scripts_test.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for Script.class.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/Scripts.class.php';
|
||||
|
||||
class PMA_Scripts_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = $this->getMockForAbstractClass('PMA_Scripts');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call private functions by making the visibitlity to public.
|
||||
*
|
||||
* @param string $name method name
|
||||
* @param array $params parameters for the invocation
|
||||
*
|
||||
* @return the output from the private method.
|
||||
*/
|
||||
private function _callPrivateFunction($name, $params)
|
||||
{
|
||||
$class = new ReflectionClass('PMA_Scripts');
|
||||
$method = $class->getMethod($name);
|
||||
$method->setAccessible(true);
|
||||
return $method->invokeArgs($this->object, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for _includeFile
|
||||
*
|
||||
* @param tring $url Location of javascript, relative to js/ folder.
|
||||
* @param int $timestamp The date when the file was last modified
|
||||
* @param string $ie_conditional true - wrap with IE conditional comment
|
||||
* 'lt 9' etc. - wrap for specific IE version
|
||||
* @param $output output from the _includeFile method
|
||||
*
|
||||
* @dataProvider providerForTestIncludeFile
|
||||
*/
|
||||
public function testIncludeFile($url, $timestamp, $ie_conditional, $output){
|
||||
$this->assertEquals(
|
||||
$this->_callPrivateFunction(
|
||||
'_includeFile',
|
||||
array($url, $timestamp, $ie_conditional)
|
||||
),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array data for testIncludeFile
|
||||
*/
|
||||
public function providerForTestIncludeFile(){
|
||||
return array(
|
||||
array(
|
||||
'common.js',
|
||||
null,
|
||||
true,
|
||||
'<!--[if IE]>
|
||||
<script src="common.js" type="text/javascript"></script>
|
||||
<![endif]-->
|
||||
'
|
||||
),
|
||||
array(
|
||||
'common.js',
|
||||
null,
|
||||
false,
|
||||
'<script src="common.js" type="text/javascript"></script>
|
||||
'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getDisplay
|
||||
*/
|
||||
public function testGetDisplay(){
|
||||
|
||||
$this->object->addFile('common.js');
|
||||
$this->object->addEvent('onClick', 'doSomething');
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getDisplay(),
|
||||
'<script src="js/common.js?ts=1339744334" type="text/javascript"></script>
|
||||
<script type="text/javascript">// <![CDATA[
|
||||
$(window.parent).bind(\'onClick\', doSomething);
|
||||
// ]]></script>'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* test for addCode
|
||||
*/
|
||||
public function testAddCode(){
|
||||
|
||||
$this->object->addCode('alert(\'CodeAdded\')');
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getDisplay(),
|
||||
'<script type="text/javascript">// <![CDATA[
|
||||
alert(\'CodeAdded\')
|
||||
// ]]></script>'
|
||||
);
|
||||
}
|
||||
}
|
||||
240
test/classes/PMA_StorageEngine_test.php
Normal file
240
test/classes/PMA_StorageEngine_test.php
Normal file
@ -0,0 +1,240 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for StorageEngine.class.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/StorageEngine.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
|
||||
class PMA_StorageEngine_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (! defined('PMA_DRIZZLE')) {
|
||||
define('PMA_DRIZZLE', 1);
|
||||
}
|
||||
if (! function_exists('PMA_DBI_fetch_result')) {
|
||||
function PMA_DBI_fetch_result($query)
|
||||
{
|
||||
return array(
|
||||
'dummy' =>'table1',
|
||||
'table`2');
|
||||
}
|
||||
}
|
||||
$this->object = $this->getMockForAbstractClass('PMA_StorageEngine', array('dummy'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
unset($this->object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getStorageEngines
|
||||
*/
|
||||
public function testGetStorageEngines(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getStorageEngines(),
|
||||
array(
|
||||
'dummy' => 'table1',
|
||||
0 => 'table`2'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getHtmlSelect
|
||||
*/
|
||||
public function testGetHtmlSelect(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getHtmlSelect(),
|
||||
'<select name="engine">
|
||||
<option value="dummy" title="t">
|
||||
t
|
||||
</option>
|
||||
<option value="0" title="t">
|
||||
t
|
||||
</option>
|
||||
</select>
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getEngine
|
||||
*/
|
||||
public function testGetEngine(){
|
||||
|
||||
$this->assertTrue(
|
||||
$this->object->getEngine('dummy') instanceof PMA_StorageEngine
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for isValid
|
||||
*/
|
||||
public function testIsValid(){
|
||||
|
||||
$this->assertTrue(
|
||||
$this->object->isValid('PBMS')
|
||||
);
|
||||
$this->assertTrue(
|
||||
$this->object->isValid('dummy')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getPage
|
||||
*/
|
||||
public function testGetPage(){
|
||||
|
||||
$this->assertFalse(
|
||||
$this->object->getPage(1)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getInfoPages
|
||||
*/
|
||||
public function testGetInfoPages(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getInfoPages(),
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getVariablesLikePattern
|
||||
*/
|
||||
public function testGetVariablesLikePattern(){
|
||||
|
||||
$this->assertFalse(
|
||||
$this->object->getVariablesLikePattern()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getMysqlHelpPage
|
||||
*/
|
||||
public function testGetMysqlHelpPage(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getMysqlHelpPage(),
|
||||
'dummy-storage-engine'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getVariables
|
||||
*/
|
||||
public function testGetVariables(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getVariables(),
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getSupportInformationMessage
|
||||
*/
|
||||
public function testGetSupportInformationMessage(){
|
||||
$this->assertEquals(
|
||||
$this->object->getSupportInformationMessage(),
|
||||
'This MySQL server does not support the t storage engine.'
|
||||
);
|
||||
|
||||
$this->object->support = 1;
|
||||
$this->assertEquals(
|
||||
$this->object->getSupportInformationMessage(),
|
||||
't has been disabled for this MySQL server.'
|
||||
);
|
||||
|
||||
$this->object->support = 2;
|
||||
$this->assertEquals(
|
||||
$this->object->getSupportInformationMessage(),
|
||||
't is available on this MySQL server.'
|
||||
);
|
||||
|
||||
$this->object->support = 3;
|
||||
$this->assertEquals(
|
||||
$this->object->getSupportInformationMessage(),
|
||||
't is the default storage engine on this MySQL server.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getComment
|
||||
*/
|
||||
public function testGetComment(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getComment(),
|
||||
't'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTitle
|
||||
*/
|
||||
public function testGetTitle(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getTitle(),
|
||||
't'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for engine_init
|
||||
*/
|
||||
public function testEngine_init(){
|
||||
|
||||
$this->assertNull(
|
||||
$this->object->engine_init()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for resolveTypeSize
|
||||
*/
|
||||
public function testResolveTypeSize(){
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->resolveTypeSize(12),
|
||||
array(
|
||||
0 => 12,
|
||||
1 => 'B'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,8 @@ require_once 'libraries/url_generating.lib.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/Theme.class.php';
|
||||
require_once 'libraries/Theme_Manager.class.php';
|
||||
require_once 'libraries/Config.class.php';
|
||||
require_once 'libraries/core.lib.php';
|
||||
|
||||
class PMA_Theme_Manager_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
@ -25,6 +27,7 @@ class PMA_Theme_Manager_test extends PHPUnit_Framework_TestCase
|
||||
$GLOBALS['cfg']['ServerDefault'] = 0;
|
||||
$GLOBALS['server'] = 99;
|
||||
$_SESSION[' PMA_token '] = 'token';
|
||||
$GLOBALS['PMA_Config'] = new PMA_Config();
|
||||
}
|
||||
|
||||
public function testCookieName()
|
||||
@ -46,5 +49,58 @@ class PMA_Theme_Manager_test extends PHPUnit_Framework_TestCase
|
||||
$this->assertContains('<option value="pmahomme" selected="selected">', $tm->getHtmlSelectBox());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for setThemeCookie
|
||||
*/
|
||||
public function testSetThemeCookie(){
|
||||
$tm = new PMA_Theme_Manager();
|
||||
$this->assertTrue(
|
||||
$tm->setThemeCookie()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for checkConfig
|
||||
*/
|
||||
public function testCheckConfig(){
|
||||
$tm = new PMA_Theme_Manager();
|
||||
$this->assertNull(
|
||||
$tm->checkConfig()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for makeBc
|
||||
*/
|
||||
public function testMakeBc(){
|
||||
$tm = new PMA_Theme_Manager();
|
||||
$this->assertNull(
|
||||
$tm->makeBc()
|
||||
);
|
||||
$this->assertEquals($GLOBALS['theme'],'pmahomme');
|
||||
$this->assertEquals($GLOBALS['pmaThemePath'],'./themes/pmahomme');
|
||||
$this->assertEquals($GLOBALS['pmaThemeImage'],'./themes/pmahomme/img/');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getPrintPreviews
|
||||
*/
|
||||
public function testGetPrintPreviews(){
|
||||
$tm = new PMA_Theme_Manager();
|
||||
$this->assertEquals(
|
||||
$tm->getPrintPreviews(),
|
||||
'<div class="theme_preview"><h2>Original (2.9) </h2><p><a target="_top" class="take_theme" name="original" href="index.php?set_theme=original&server=99&token=token"><img src="./themes/original/screen.png" border="1" alt="Original" title="Original" /><br />[ <strong>take it</strong> ]</a></p></div><div class="theme_preview"><h2>pmahomme (1.1) </h2><p><a target="_top" class="take_theme" name="pmahomme" href="index.php?set_theme=pmahomme&server=99&token=token"><img src="./themes/pmahomme/screen.png" border="1" alt="pmahomme" title="pmahomme" /><br />[ <strong>take it</strong> ]</a></p></div>'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getFallBackTheme
|
||||
*/
|
||||
public function testGetFallBackTheme(){
|
||||
$tm = new PMA_Theme_Manager();
|
||||
$this->assertTrue($tm->getFallBackTheme() instanceof PMA_Theme);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@ -8,6 +8,7 @@ require_once 'libraries/Config.class.php';
|
||||
require_once 'libraries/Theme_Manager.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/sqlparser.lib.php';
|
||||
require_once 'libraries/url_generating.lib.php';
|
||||
|
||||
/**
|
||||
* Test class for PMA_Theme.
|
||||
@ -214,30 +215,197 @@ class PMA_ThemeTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for loading CSS files.
|
||||
*
|
||||
* @return nothing
|
||||
*
|
||||
* @todo Needs to be revisited as original test is somehow broken.
|
||||
*/
|
||||
public function testLoadCss()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test seems to cause some problems in output buffering handling'
|
||||
);
|
||||
//$this->expectOutputRegex('/.*FILE: codemirror.css.php.*/');
|
||||
//$this->assertTrue($this->object->loadCss());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @todo Implement testPrintPreview().
|
||||
* Test for getPrintPreview().
|
||||
*/
|
||||
public function testPrintPreview()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
$this->assertEquals(
|
||||
$this->object->getPrintPreview(),
|
||||
'<div class="theme_preview"><h2> (0.0.0.0) </h2><p><a target="_top" class="take_theme" name="" href="index.php?set_theme=">No preview available.[ <strong>take it</strong> ]</a></p></div>'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getCssIEClearFilter
|
||||
*/
|
||||
public function testGetCssIEClearFilter(){
|
||||
$this->assertEquals(
|
||||
$this->object->getCssIEClearFilter(),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getFontSize
|
||||
*/
|
||||
public function testGetFontSize(){
|
||||
$this->assertEquals(
|
||||
$this->object->getFontSize(),
|
||||
'82%'
|
||||
);
|
||||
|
||||
$_COOKIE['pma_fontsize'] = '14px';
|
||||
$this->assertEquals(
|
||||
$this->object->getFontSize(),
|
||||
'14px'
|
||||
);
|
||||
|
||||
$GLOBALS['PMA_Config']->set('fontsize','12px');
|
||||
$this->assertEquals(
|
||||
$this->object->getFontSize(),
|
||||
'12px'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getCssGradient
|
||||
*/
|
||||
public function testgetCssGradient(){
|
||||
$this->assertEquals(
|
||||
$this->object->getCssGradient('12345', '54321'),
|
||||
'background-image: url(./themes/svg_gradient.php?from=12345&to=54321);
|
||||
background-size: 100% 100%;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#12345), to(#54321));
|
||||
background: -webkit-linear-gradient(top, #12345, #54321);
|
||||
background: -moz-linear-gradient(top, #12345, #54321);
|
||||
background: -ms-linear-gradient(top, #12345, #54321);
|
||||
background: -o-linear-gradient(top, #12345, #54321);'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getCssCodeMirror
|
||||
*/
|
||||
public function testGetCssCodeMirror(){
|
||||
$this->assertEquals(
|
||||
$this->object->getCssCodeMirror(),
|
||||
'span.cm-keyword, span.cm-statement-verb {
|
||||
color: #909;
|
||||
}
|
||||
span.cm-variable {
|
||||
color: black;
|
||||
}
|
||||
span.cm-comment {
|
||||
color: #808000;
|
||||
}
|
||||
span.cm-mysql-string {
|
||||
color: #008000;
|
||||
}
|
||||
span.cm-operator {
|
||||
color: fuchsia;
|
||||
}
|
||||
span.cm-mysql-word {
|
||||
color: black;
|
||||
}
|
||||
span.cm-builtin {
|
||||
color: #f00;
|
||||
}
|
||||
span.cm-variable-2 {
|
||||
color: #f90;
|
||||
}
|
||||
span.cm-variable-3 {
|
||||
color: #00f;
|
||||
}
|
||||
span.cm-separator {
|
||||
color: fuchsia;
|
||||
}
|
||||
span.cm-number {
|
||||
color: teal;
|
||||
}'
|
||||
);
|
||||
|
||||
$GLOBALS['cfg']['CodemirrorEnable'] = false;
|
||||
$this->assertEquals(
|
||||
$this->object->getCssCodeMirror(),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getImgPath
|
||||
* @param string $file file name for image
|
||||
* @param $output
|
||||
*
|
||||
* @dataProvider providerForGetImgPath
|
||||
*/
|
||||
public function testGetImgPath($file, $output){
|
||||
$this->assertEquals(
|
||||
$this->object->getImgPath($file),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for testGetImgPath
|
||||
* @return array
|
||||
*/
|
||||
public function providerForGetImgPath(){
|
||||
return array(
|
||||
array(
|
||||
null,
|
||||
''
|
||||
),
|
||||
array(
|
||||
'screen.png',
|
||||
'./themes/pmahomme/img/screen.png'
|
||||
),
|
||||
array(
|
||||
'arrow_ltr.png',
|
||||
'./themes/pmahomme/img/arrow_ltr.png'
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for buildSQPCssRule
|
||||
*/
|
||||
public function testBuildSQPCssRule(){
|
||||
$this->assertEquals(
|
||||
$this->object->buildSQPCssRule('PMA_Config', 'fontSize', '12px'),
|
||||
'.PMA_Config {fontSize: 12px;}
|
||||
'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for buildSQPCssData
|
||||
*/
|
||||
public function testBuildSQPCssData(){
|
||||
$this->assertEquals(
|
||||
$this->object->buildSQPCssData(),
|
||||
'.syntax_comment {color: #808000;}
|
||||
.syntax_comment_mysql {}
|
||||
.syntax_comment_ansi {}
|
||||
.syntax_comment_c {}
|
||||
.syntax_digit {}
|
||||
.syntax_digit_hex {color: teal;}
|
||||
.syntax_digit_integer {color: teal;}
|
||||
.syntax_digit_float {color: aqua;}
|
||||
.syntax_punct {color: fuchsia;}
|
||||
.syntax_alpha {}
|
||||
.syntax_alpha_columnType {color: #f90;}
|
||||
.syntax_alpha_columnAttrib {color: #00f;}
|
||||
.syntax_alpha_reservedWord {color: #909;}
|
||||
.syntax_alpha_functionName {color: #f00;}
|
||||
.syntax_alpha_identifier {color: black;}
|
||||
.syntax_alpha_charset {color: #6495ed;}
|
||||
.syntax_alpha_variable {color: #800000;}
|
||||
.syntax_quote {color: #008000;}
|
||||
.syntax_quote_double {}
|
||||
.syntax_quote_single {}
|
||||
.syntax_quote_backtick {}
|
||||
.syntax_indent0 {margin-left: 0em;}
|
||||
.syntax_indent1 {margin-left: 1em;}
|
||||
.syntax_indent2 {margin-left: 2em;}
|
||||
.syntax_indent3 {margin-left: 3em;}
|
||||
.syntax_indent4 {margin-left: 4em;}
|
||||
.syntax_indent5 {margin-left: 5em;}
|
||||
.syntax_indent6 {margin-left: 6em;}
|
||||
.syntax_indent7 {margin-left: 7em;}
|
||||
'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
366
test/classes/PMA_Types_Drizzle_test.php
Normal file
366
test/classes/PMA_Types_Drizzle_test.php
Normal file
@ -0,0 +1,366 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for Types.class.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/Types.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_Types_Drizzle_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var PMA_Types
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = new PMA_Types_Drizzle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTypeDescription
|
||||
*
|
||||
* @param string $type The data type to get a description.
|
||||
* @param $output string
|
||||
*
|
||||
* @dataProvider providerForTestGetTypeDescription
|
||||
*/
|
||||
public function testGetTypeDescription($type, $output){
|
||||
$this->assertEquals(
|
||||
$this->object->getTypeDescription($type),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for testGetTypeDescription
|
||||
* @return array
|
||||
*/
|
||||
public function providerForTestGetTypeDescription(){
|
||||
return array(
|
||||
array(
|
||||
'INTEGER',
|
||||
'A 4-byte integer, range is -2,147,483,648 to 2,147,483,647'
|
||||
),
|
||||
array(
|
||||
'BIGINT',
|
||||
'An 8-byte integer, range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807'
|
||||
),
|
||||
array(
|
||||
'DECIMAL',
|
||||
'A fixed-point number (M, D) - the maximum number of digits (M) is 65 (default 10), the maximum number of decimals (D) is 30 (default 0)'
|
||||
),
|
||||
array(
|
||||
'DOUBLE',
|
||||
'A system\'s default double-precision floating-point number'
|
||||
),
|
||||
array(
|
||||
'BOOLEAN',
|
||||
'True or false'
|
||||
),
|
||||
array(
|
||||
'SERIAL',
|
||||
'An alias for BIGINT NOT NULL AUTO_INCREMENT UNIQUE'
|
||||
),
|
||||
array(
|
||||
'UUID',
|
||||
'Stores a Universally Unique Identifier (UUID)'
|
||||
),
|
||||
array(
|
||||
'DATE',
|
||||
'A date, supported range is 0001-01-01 to 9999-12-31'
|
||||
),
|
||||
array(
|
||||
'DATETIME',
|
||||
'A date and time combination, supported range is 0001-01-01 00:00:0 to 9999-12-31 23:59:59'
|
||||
),
|
||||
array(
|
||||
'TIMESTAMP',
|
||||
'A timestamp, range is \'0001-01-01 00:00:00\' UTC to \'9999-12-31 23:59:59\' UTC; TIMESTAMP(6) can store microseconds'
|
||||
),
|
||||
array(
|
||||
'TIME',
|
||||
'A time, range is 00:00:00 to 23:59:59'
|
||||
),
|
||||
array(
|
||||
'VARCHAR',
|
||||
'A variable-length (0-16,383) string, the effective maximum length is subject to the maximum row size'
|
||||
),
|
||||
array(
|
||||
'TEXT',
|
||||
'A TEXT column with a maximum length of 65,535 (2^16 - 1) characters, stored with a two-byte prefix indicating the length of the value in bytes'
|
||||
),
|
||||
array(
|
||||
'VARBINARY',
|
||||
'A variable-length (0-65,535) string, uses binary collation for all comparisons'
|
||||
),
|
||||
array(
|
||||
'BLOB',
|
||||
'A BLOB column with a maximum length of 65,535 (2^16 - 1) bytes, stored with a four-byte prefix indicating the length of the value'
|
||||
),
|
||||
array(
|
||||
'ENUM',
|
||||
'An enumeration, chosen from the list of defined values'
|
||||
),
|
||||
array(
|
||||
'UNKNOWN',
|
||||
''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTypeClass
|
||||
*
|
||||
* @param $type
|
||||
* @param $output
|
||||
*
|
||||
* @dataProvider providerFortTestGetTypeClass
|
||||
*/
|
||||
public function testGetTypeClass($type, $output){
|
||||
$this->assertEquals(
|
||||
$this->object->getTypeClass($type),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
public function providerFortTestGetTypeClass(){
|
||||
return array(
|
||||
array(
|
||||
'SERIAL',
|
||||
'NUMBER'
|
||||
),
|
||||
array(
|
||||
'TIME',
|
||||
'DATE'
|
||||
),
|
||||
array(
|
||||
'ENUM',
|
||||
'CHAR'
|
||||
),
|
||||
array(
|
||||
'UUID',
|
||||
'UUID'
|
||||
),
|
||||
array(
|
||||
'UNKNOWN',
|
||||
''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getFunctionsClass
|
||||
*
|
||||
* @param string $class The class to get function list.
|
||||
* @param $output array
|
||||
*
|
||||
* @dataProvider providerFortTestGetFunctionsClass
|
||||
*/
|
||||
public function testGetFunctionsClass($class, $output){
|
||||
|
||||
if (! function_exists('PMA_DBI_fetch_result')) {
|
||||
function PMA_DBI_fetch_result($query)
|
||||
{
|
||||
return array('table1', 'table`2');
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getFunctionsClass($class),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for testGetFunctionsClass
|
||||
* @return array
|
||||
*/
|
||||
public function providerFortTestGetFunctionsClass(){
|
||||
return array(
|
||||
array(
|
||||
'UUID',
|
||||
array(
|
||||
'UUID'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'DATE',
|
||||
array(
|
||||
'CURRENT_DATE',
|
||||
'CURRENT_TIME',
|
||||
'DATE',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'LAST_DAY',
|
||||
'NOW',
|
||||
'SYSDATE',
|
||||
'TIMESTAMP',
|
||||
'UTC_DATE',
|
||||
'UTC_TIME',
|
||||
'UTC_TIMESTAMP',
|
||||
'YEAR',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'NUMBER',
|
||||
array(
|
||||
'ABS',
|
||||
'ACOS',
|
||||
'ASCII',
|
||||
'ASIN',
|
||||
'ATAN',
|
||||
'BIT_COUNT',
|
||||
'CEILING',
|
||||
'CHAR_LENGTH',
|
||||
'CONNECTION_ID',
|
||||
'COS',
|
||||
'COT',
|
||||
'CRC32',
|
||||
'DAYOFMONTH',
|
||||
'DAYOFWEEK',
|
||||
'DAYOFYEAR',
|
||||
'DEGREES',
|
||||
'EXP',
|
||||
'FLOOR',
|
||||
'HOUR',
|
||||
'LENGTH',
|
||||
'LN',
|
||||
'LOG',
|
||||
'LOG2',
|
||||
'LOG10',
|
||||
'MICROSECOND',
|
||||
'MINUTE',
|
||||
'MONTH',
|
||||
'OCT',
|
||||
'ORD',
|
||||
'PI',
|
||||
'QUARTER',
|
||||
'RADIANS',
|
||||
'RAND',
|
||||
'ROUND',
|
||||
'SECOND',
|
||||
'SIGN',
|
||||
'SIN',
|
||||
'SQRT',
|
||||
'TAN',
|
||||
'TO_DAYS',
|
||||
'TIME_TO_SEC',
|
||||
'UNCOMPRESSED_LENGTH',
|
||||
'UNIX_TIMESTAMP',
|
||||
//'WEEK', // same as TIME
|
||||
'WEEKDAY',
|
||||
'WEEKOFYEAR',
|
||||
'YEARWEEK',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'CHAR',
|
||||
array(
|
||||
0 => 'BIN',
|
||||
1 => 'CHAR',
|
||||
2 => 'COMPRESS',
|
||||
3 => 'CURRENT_USER',
|
||||
4 => 'DATABASE',
|
||||
5 => 'DAYNAME',
|
||||
6 => 'HEX',
|
||||
7 => 'LOAD_FILE',
|
||||
8 => 'LOWER',
|
||||
9 => 'LTRIM',
|
||||
10 => 'MD5',
|
||||
11 => 'MONTHNAME',
|
||||
12 => 'QUOTE',
|
||||
13 => 'REVERSE',
|
||||
14 => 'RTRIM',
|
||||
15 => 'SCHEMA',
|
||||
16 => 'SPACE',
|
||||
17 => 'TRIM',
|
||||
18 => 'UNCOMPRESS',
|
||||
19 => 'UNHEX',
|
||||
20 => 'UPPER',
|
||||
21 => 'USER',
|
||||
22 => 'UUID',
|
||||
23 => 'VERSION',
|
||||
24 => 'table1',
|
||||
25 => 'table`2'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'UNKNOWN',
|
||||
array()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getAttributes
|
||||
*/
|
||||
public function testGetAttributes(){
|
||||
$this->assertEquals(
|
||||
$this->object->getAttributes(),
|
||||
array(
|
||||
'',
|
||||
'on update CURRENT_TIMESTAMP',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getColumns
|
||||
*/
|
||||
public function testGetColumns(){
|
||||
|
||||
if (! defined('PMA_MYSQL_INT_VERSION')) {
|
||||
define('PMA_MYSQL_INT_VERSION', 20120130);
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getColumns(),
|
||||
array(
|
||||
0 => 'INT',
|
||||
1 => 'VARCHAR',
|
||||
2 => 'TEXT',
|
||||
3 => 'DATE',
|
||||
'Numeric' => array (
|
||||
'INTEGER',
|
||||
'BIGINT',
|
||||
'-',
|
||||
'DECIMAL',
|
||||
'DOUBLE',
|
||||
'-',
|
||||
'BOOLEAN',
|
||||
'SERIAL',
|
||||
'UUID',
|
||||
),
|
||||
'Date and time' => array (
|
||||
'DATE',
|
||||
'DATETIME',
|
||||
'TIMESTAMP',
|
||||
'TIME',
|
||||
),
|
||||
'String' => array (
|
||||
'VARCHAR',
|
||||
'TEXT',
|
||||
'-',
|
||||
'VARBINARY',
|
||||
'BLOB',
|
||||
'-',
|
||||
'ENUM',
|
||||
'-',
|
||||
'IPV6'
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
500
test/classes/PMA_Types_MySQL_test.php
Normal file
500
test/classes/PMA_Types_MySQL_test.php
Normal file
@ -0,0 +1,500 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for Types.class.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/Types.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_Types_MySQL_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var PMA_Types
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = new PMA_Types_MySQL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTypeDescription
|
||||
*
|
||||
* @param string $type The data type to get a description.
|
||||
* @param $output string
|
||||
*
|
||||
* @dataProvider providerForTestGetTypeDescription
|
||||
*/
|
||||
public function testGetTypeDescription($type, $output){
|
||||
$this->assertEquals(
|
||||
$this->object->getTypeDescription($type),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for testGetTypeDescription
|
||||
* @return array
|
||||
*/
|
||||
public function providerForTestGetTypeDescription(){
|
||||
return array(
|
||||
array(
|
||||
'TINYINT',
|
||||
'A 1-byte integer, signed range is -128 to 127, unsigned range is 0 to 255'
|
||||
),
|
||||
array(
|
||||
'SMALLINT',
|
||||
'A 2-byte integer, signed range is -32,768 to 32,767, unsigned range is 0 to 65,535'
|
||||
),
|
||||
array(
|
||||
'MEDIUMINT',
|
||||
'A 3-byte integer, signed range is -8,388,608 to 8,388,607, unsigned range is 0 to 16,777,215'
|
||||
),
|
||||
array(
|
||||
'INT',
|
||||
'A 4-byte integer, signed range is -2,147,483,648 to 2,147,483,647, unsigned range is 0 to 4,294,967,295.'
|
||||
),
|
||||
array(
|
||||
'BIGINT',
|
||||
'An 8-byte integer, signed range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, unsigned range is 0 to 18,446,744,073,709,551,615'
|
||||
),
|
||||
array(
|
||||
'DECIMAL',
|
||||
'A fixed-point number (M, D) - the maximum number of digits (M) is 65 (default 10), the maximum number of decimals (D) is 30 (default 0)'
|
||||
),
|
||||
array(
|
||||
'FLOAT',
|
||||
'A small floating-point number, allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38'
|
||||
),
|
||||
array(
|
||||
'DOUBLE',
|
||||
'A double-precision floating-point number, allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308'
|
||||
),
|
||||
array(
|
||||
'REAL',
|
||||
'Synonym for DOUBLE (exception: in REAL_AS_FLOAT SQL mode it is a synonym for FLOAT)'
|
||||
),
|
||||
array(
|
||||
'BIT',
|
||||
'A bit-field type (M), storing M of bits per value (default is 1, maximum is 64)'
|
||||
),
|
||||
array(
|
||||
'BOOLEAN',
|
||||
'A synonym for TINYINT(1), a value of zero is considered false, nonzero values are considered true'
|
||||
),
|
||||
array(
|
||||
'SERIAL',
|
||||
'An alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE'
|
||||
),
|
||||
array(
|
||||
'DATE',
|
||||
'A date, supported range is 1000-01-01 to 9999-12-31'
|
||||
),
|
||||
array(
|
||||
'DATETIME',
|
||||
'A date and time combination, supported range is 1000-01-01 00:00:00 to 9999-12-31 23:59:59'
|
||||
),
|
||||
array(
|
||||
'TIMESTAMP',
|
||||
'A timestamp, range is 1970-01-01 00:00:01 UTC to 2038-01-09 03:14:07 UTC, stored as the number of seconds since the epoch (1970-01-01 00:00:00 UTC)'
|
||||
),
|
||||
array(
|
||||
'TIME',
|
||||
'A time, range is -838:59:59 to 838:59:59'
|
||||
),
|
||||
array(
|
||||
'YEAR',
|
||||
'A year in four-digit (4, default) or two-digit (2) format, the allowable values are 70 (1970) to 69 (2069) or 1901 to 2155 and 0000'
|
||||
),
|
||||
array(
|
||||
'CHAR',
|
||||
'A fixed-length (0-255, default 1) string that is always right-padded with spaces to the specified length when stored'
|
||||
),
|
||||
array(
|
||||
'VARCHAR',
|
||||
'A variable-length (0-65,535) string, the effective maximum length is subject to the maximum row size'
|
||||
),
|
||||
array(
|
||||
'TINYTEXT',
|
||||
'A TEXT column with a maximum length of 255 (2^8 - 1) characters, stored with a one-byte prefix indicating the length of the value in bytes'
|
||||
),
|
||||
array(
|
||||
'TEXT',
|
||||
'A TEXT column with a maximum length of 65,535 (2^16 - 1) characters, stored with a two-byte prefix indicating the length of the value in bytes'
|
||||
),
|
||||
array(
|
||||
'MEDIUMTEXT',
|
||||
'A TEXT column with a maximum length of 16,777,215 (2^24 - 1) characters, stored with a three-byte prefix indicating the length of the value in bytes'
|
||||
),
|
||||
array(
|
||||
'LONGTEXT',
|
||||
'A TEXT column with a maximum length of 4,294,967,295 or 4GiB (2^32 - 1) characters, stored with a four-byte prefix indicating the length of the value in bytes'
|
||||
),
|
||||
array(
|
||||
'BINARY',
|
||||
'Similar to the CHAR type, but stores binary byte strings rather than non-binary character strings'
|
||||
),
|
||||
array(
|
||||
'VARBINARY',
|
||||
'Similar to the VARCHAR type, but stores binary byte strings rather than non-binary character strings'
|
||||
),
|
||||
array(
|
||||
'TINYBLOB',
|
||||
'A BLOB column with a maximum length of 255 (2^8 - 1) bytes, stored with a one-byte prefix indicating the length of the value'
|
||||
),
|
||||
array(
|
||||
'MEDIUMBLOB',
|
||||
'A BLOB column with a maximum length of 16,777,215 (2^24 - 1) bytes, stored with a three-byte prefix indicating the length of the value'
|
||||
),
|
||||
array(
|
||||
'BLOB',
|
||||
'A BLOB column with a maximum length of 65,535 (2^16 - 1) bytes, stored with a two-byte prefix indicating the length of the value'
|
||||
),
|
||||
array(
|
||||
'LONGBLOB',
|
||||
'A BLOB column with a maximum length of 4,294,967,295 or 4GiB (2^32 - 1) bytes, stored with a four-byte prefix indicating the length of the value'
|
||||
),
|
||||
array(
|
||||
'ENUM',
|
||||
'An enumeration, chosen from the list of up to 65,535 values or the special \'\' error value'
|
||||
),
|
||||
array(
|
||||
'SET',
|
||||
'A single value chosen from a set of up to 64 members'
|
||||
),
|
||||
array(
|
||||
'GEOMETRY',
|
||||
'A type that can store a geometry of any type'
|
||||
),
|
||||
array(
|
||||
'POINT',
|
||||
'A point in 2-dimensional space'
|
||||
),
|
||||
array(
|
||||
'LINESTRING',
|
||||
'A curve with linear interpolation between points'
|
||||
),
|
||||
array(
|
||||
'POLYGON',
|
||||
'A polygon'
|
||||
),
|
||||
array(
|
||||
'MULTIPOINT',
|
||||
'A collection of points'
|
||||
),
|
||||
array(
|
||||
'MULTILINESTRING',
|
||||
'A collection of curves with linear interpolation between points'
|
||||
),
|
||||
array(
|
||||
'MULTIPOLYGON',
|
||||
'A collection of polygons'
|
||||
),
|
||||
array(
|
||||
'GEOMETRYCOLLECTION',
|
||||
'A collection of geometry objects of any type'
|
||||
),
|
||||
array(
|
||||
'UNKNOWN',
|
||||
''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTypeClass
|
||||
*
|
||||
* @param $type
|
||||
* @param $output
|
||||
*
|
||||
* @dataProvider providerFortTestGetTypeClass
|
||||
*/
|
||||
public function testGetTypeClass($type, $output){
|
||||
$this->assertEquals(
|
||||
$this->object->getTypeClass($type),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
public function providerFortTestGetTypeClass(){
|
||||
return array(
|
||||
array(
|
||||
'SERIAL',
|
||||
'NUMBER'
|
||||
),
|
||||
array(
|
||||
'YEAR',
|
||||
'DATE'
|
||||
),
|
||||
array(
|
||||
'GEOMETRYCOLLECTION',
|
||||
'SPATIAL'
|
||||
),
|
||||
array(
|
||||
'SET',
|
||||
'CHAR'
|
||||
),
|
||||
array(
|
||||
'UNKNOWN',
|
||||
''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getFunctionsClass
|
||||
*
|
||||
* @param string $class The class to get function list.
|
||||
* @param $output array
|
||||
*
|
||||
* @dataProvider providerFortTestGetFunctionsClass
|
||||
*/
|
||||
public function testGetFunctionsClass($class, $output){
|
||||
|
||||
if (! defined('PMA_MYSQL_INT_VERSION')) {
|
||||
define('PMA_MYSQL_INT_VERSION', 50000);
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
$this->object->getFunctionsClass($class),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
public function providerFortTestGetFunctionsClass(){
|
||||
return array(
|
||||
array(
|
||||
'CHAR',
|
||||
array(
|
||||
'BIN',
|
||||
'CHAR',
|
||||
'CURRENT_USER',
|
||||
'COMPRESS',
|
||||
'DATABASE',
|
||||
'DAYNAME',
|
||||
'DES_DECRYPT',
|
||||
'DES_ENCRYPT',
|
||||
'ENCRYPT',
|
||||
'HEX',
|
||||
'INET_NTOA',
|
||||
'LOAD_FILE',
|
||||
'LOWER',
|
||||
'LTRIM',
|
||||
'MD5',
|
||||
'MONTHNAME',
|
||||
'OLD_PASSWORD',
|
||||
'PASSWORD',
|
||||
'QUOTE',
|
||||
'REVERSE',
|
||||
'RTRIM',
|
||||
'SHA1',
|
||||
'SOUNDEX',
|
||||
'SPACE',
|
||||
'TRIM',
|
||||
'UNCOMPRESS',
|
||||
'UNHEX',
|
||||
'UPPER',
|
||||
'USER',
|
||||
'UUID',
|
||||
'VERSION',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'DATE',
|
||||
array(
|
||||
'CURRENT_DATE',
|
||||
'CURRENT_TIME',
|
||||
'DATE',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'LAST_DAY',
|
||||
'NOW',
|
||||
'SEC_TO_TIME',
|
||||
'SYSDATE',
|
||||
'TIME',
|
||||
'TIMESTAMP',
|
||||
'UTC_DATE',
|
||||
'UTC_TIME',
|
||||
'UTC_TIMESTAMP',
|
||||
'YEAR',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'SPATIAL',
|
||||
array(
|
||||
'GeomFromText',
|
||||
'GeomFromWKB',
|
||||
|
||||
'GeomCollFromText',
|
||||
'LineFromText',
|
||||
'MLineFromText',
|
||||
'PointFromText',
|
||||
'MPointFromText',
|
||||
'PolyFromText',
|
||||
'MPolyFromText',
|
||||
|
||||
'GeomCollFromWKB',
|
||||
'LineFromWKB',
|
||||
'MLineFromWKB',
|
||||
'PointFromWKB',
|
||||
'MPointFromWKB',
|
||||
'PolyFromWKB',
|
||||
'MPolyFromWKB',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'NUMBER',
|
||||
array(
|
||||
'0' => 'ABS',
|
||||
'1' => 'ACOS',
|
||||
'2' => 'ASCII',
|
||||
'3' => 'ASIN',
|
||||
'4' => 'ATAN',
|
||||
'5' => 'BIT_LENGTH',
|
||||
'6' => 'BIT_COUNT',
|
||||
'7' => 'CEILING',
|
||||
'8' => 'CHAR_LENGTH',
|
||||
'9' => 'CONNECTION_ID',
|
||||
'10' => 'COS',
|
||||
'11' => 'COT',
|
||||
'12' => 'CRC32',
|
||||
'13' => 'DAYOFMONTH',
|
||||
'14' => 'DAYOFWEEK',
|
||||
'15' => 'DAYOFYEAR',
|
||||
'16' => 'DEGREES',
|
||||
'17' => 'EXP',
|
||||
'18' => 'FLOOR',
|
||||
'19' => 'HOUR',
|
||||
'20' => 'INET_ATON',
|
||||
'21' => 'LENGTH',
|
||||
'22' => 'LN',
|
||||
'23' => 'LOG',
|
||||
'24' => 'LOG2',
|
||||
'25' => 'LOG10',
|
||||
'26' => 'MICROSECOND',
|
||||
'27' => 'MINUTE',
|
||||
'28' => 'MONTH',
|
||||
'29' => 'OCT',
|
||||
'30' => 'ORD',
|
||||
'31' => 'PI',
|
||||
'32' => 'QUARTER',
|
||||
'33' => 'RADIANS',
|
||||
'34' => 'RAND',
|
||||
'35' => 'ROUND',
|
||||
'36' => 'SECOND',
|
||||
'37' => 'SIGN',
|
||||
'38' => 'SIN',
|
||||
'39' => 'SQRT',
|
||||
'40' => 'TAN',
|
||||
'41' => 'TO_DAYS',
|
||||
'43' => 'TIME_TO_SEC',
|
||||
'44' => 'UNCOMPRESSED_LENGTH',
|
||||
'45' => 'UNIX_TIMESTAMP',
|
||||
'47' => 'WEEK',
|
||||
'48' => 'WEEKDAY',
|
||||
'49' => 'WEEKOFYEAR',
|
||||
'50' => 'YEARWEEK'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'UNKNOWN',
|
||||
array()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getAttributes
|
||||
*/
|
||||
public function testGetAttributes(){
|
||||
$this->assertEquals(
|
||||
$this->object->getAttributes(),
|
||||
array(
|
||||
'',
|
||||
'BINARY',
|
||||
'UNSIGNED',
|
||||
'UNSIGNED ZEROFILL',
|
||||
'on update CURRENT_TIMESTAMP',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getColumns
|
||||
*/
|
||||
public function testGetColumns(){
|
||||
$this->assertEquals(
|
||||
$this->object->getColumns(),
|
||||
array(
|
||||
0 => 'INT',
|
||||
1 => 'VARCHAR',
|
||||
2 => 'TEXT',
|
||||
3 => 'DATE',
|
||||
'Numeric' => array (
|
||||
'TINYINT',
|
||||
'SMALLINT',
|
||||
'MEDIUMINT',
|
||||
'INT',
|
||||
'BIGINT',
|
||||
'-',
|
||||
'DECIMAL',
|
||||
'FLOAT',
|
||||
'DOUBLE',
|
||||
'REAL',
|
||||
'-',
|
||||
'BIT',
|
||||
'BOOLEAN',
|
||||
'SERIAL',
|
||||
),
|
||||
'Date and time' => array (
|
||||
'DATE',
|
||||
'DATETIME',
|
||||
'TIMESTAMP',
|
||||
'TIME',
|
||||
'YEAR',
|
||||
),
|
||||
'String' => array (
|
||||
'CHAR',
|
||||
'VARCHAR',
|
||||
'-',
|
||||
'TINYTEXT',
|
||||
'TEXT',
|
||||
'MEDIUMTEXT',
|
||||
'LONGTEXT',
|
||||
'-',
|
||||
'BINARY',
|
||||
'VARBINARY',
|
||||
'-',
|
||||
'TINYBLOB',
|
||||
'MEDIUMBLOB',
|
||||
'BLOB',
|
||||
'LONGBLOB',
|
||||
'-',
|
||||
'ENUM',
|
||||
'SET',
|
||||
),
|
||||
'Spatial' => array (
|
||||
'GEOMETRY',
|
||||
'POINT',
|
||||
'LINESTRING',
|
||||
'POLYGON',
|
||||
'MULTIPOINT',
|
||||
'MULTILINESTRING',
|
||||
'MULTIPOLYGON',
|
||||
'GEOMETRYCOLLECTION',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Tests for Types.class.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/Types.class.php';
|
||||
|
||||
@ -19,13 +27,254 @@ class PMA_TypesTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->object = new PMA_Types;
|
||||
$this->object = new PMA_Types();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for isUnaryOperator
|
||||
*/
|
||||
public function testUnary()
|
||||
{
|
||||
$this->assertTrue($this->object->isUnaryOperator('IS NULL'));
|
||||
$this->assertFalse($this->object->isUnaryOperator('='));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getUnaryOperators
|
||||
*/
|
||||
public function testGetUnaryOperators(){
|
||||
$this->assertEquals($this->object->getUnaryOperators(),
|
||||
array(
|
||||
'IS NULL',
|
||||
'IS NOT NULL',
|
||||
"= ''",
|
||||
"!= ''",
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getNullOperators
|
||||
*/
|
||||
public function testGetNullOperators(){
|
||||
$this->assertEquals($this->object->getNullOperators(),
|
||||
array(
|
||||
'IS NULL',
|
||||
'IS NOT NULL',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getEnumOperators
|
||||
*/
|
||||
public function testGetEnumOperators(){
|
||||
$this->assertEquals($this->object->getEnumOperators(),
|
||||
array(
|
||||
'=',
|
||||
'!=',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTextOperators
|
||||
*/
|
||||
public function testgetTextOperators(){
|
||||
$this->assertEquals($this->object->getTextOperators(),
|
||||
array(
|
||||
'LIKE',
|
||||
'LIKE %...%',
|
||||
'NOT LIKE',
|
||||
'=',
|
||||
'!=',
|
||||
'REGEXP',
|
||||
'REGEXP ^...$',
|
||||
'NOT REGEXP',
|
||||
"= ''",
|
||||
"!= ''",
|
||||
'IN (...)',
|
||||
'NOT IN (...)',
|
||||
'BETWEEN',
|
||||
'NOT BETWEEN',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getNumberOperators
|
||||
*/
|
||||
public function testGetNumberOperators(){
|
||||
$this->assertEquals($this->object->getNumberOperators(),
|
||||
array(
|
||||
'=',
|
||||
'>',
|
||||
'>=',
|
||||
'<',
|
||||
'<=',
|
||||
'!=',
|
||||
'LIKE',
|
||||
'NOT LIKE',
|
||||
'IN (...)',
|
||||
'NOT IN (...)',
|
||||
'BETWEEN',
|
||||
'NOT BETWEEN',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type Type of field
|
||||
* @param boolean $null Whether field can be NULL
|
||||
* @param $output
|
||||
*
|
||||
* @dataProvider providerForGetTypeOperators
|
||||
*/
|
||||
public function testGetTypeOperators($type, $null, $output){
|
||||
$this->assertEquals(
|
||||
$this->object->getTypeOperators($type, $null),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* data provider for testGetTypeOperators
|
||||
*/
|
||||
public function providerForGetTypeOperators(){
|
||||
return array(
|
||||
array(
|
||||
'enum',
|
||||
false,
|
||||
array(
|
||||
'=',
|
||||
'!=',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'CHAR',
|
||||
true,
|
||||
array(
|
||||
'=',
|
||||
'>',
|
||||
'>=',
|
||||
'<',
|
||||
'<=',
|
||||
'!=',
|
||||
'LIKE',
|
||||
'NOT LIKE',
|
||||
'IN (...)',
|
||||
'NOT IN (...)',
|
||||
'BETWEEN',
|
||||
'NOT BETWEEN',
|
||||
'IS NULL',
|
||||
'IS NOT NULL',
|
||||
),
|
||||
array(
|
||||
'int',
|
||||
false,
|
||||
array(
|
||||
'=',
|
||||
'!=',
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTypeOperatorsHtml
|
||||
*
|
||||
* @param string $type Type of field
|
||||
* @param boolean $null Whether field can be NULL
|
||||
* @param string $selectedOperator Option to be selected
|
||||
* @param $output
|
||||
*
|
||||
* @dataProvider providerForTestGetTypeOperatorsHtml
|
||||
*/
|
||||
public function testGetTypeOperatorsHtml($type, $null, $selectedOperator, $output){
|
||||
$this->assertEquals(
|
||||
$this->object->getTypeOperatorsHtml($type, $null, $selectedOperator),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for testGetTypeOperatorsHtml
|
||||
*/
|
||||
public function providerForTestGetTypeOperatorsHtml(){
|
||||
return array(
|
||||
array(
|
||||
'enum',
|
||||
false,
|
||||
'=',
|
||||
'<option value="=" selected="selected">=</option><option value="!=">!=</option>'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getTypeDescription
|
||||
*/
|
||||
public function testGetTypeDescription(){
|
||||
$this->assertEquals(
|
||||
$this->object->getTypeDescription('enum'),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getFunctionsClass
|
||||
*/
|
||||
public function testGetFunctionsClass(){
|
||||
$this->assertEquals(
|
||||
$this->object->getFunctionsClass('enum'),
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getFunctions
|
||||
*/
|
||||
public function testGetFunctions(){
|
||||
$this->assertEquals(
|
||||
$this->object->getFunctions('enum'),
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getAllFunctions
|
||||
*/
|
||||
public function testGetAllFunctions(){
|
||||
$this->assertEquals(
|
||||
$this->object->getAllFunctions(),
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getAttributes
|
||||
*/
|
||||
public function testGetAttributes(){
|
||||
$this->assertEquals(
|
||||
$this->object->getAttributes(),
|
||||
array()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getColumns
|
||||
*/
|
||||
public function testGetColumns(){
|
||||
$this->assertEquals(
|
||||
$this->object->getColumns(),
|
||||
array(
|
||||
'INT',
|
||||
'VARCHAR',
|
||||
'TEXT',
|
||||
'DATE',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -15,28 +15,6 @@ require_once 'libraries/gis/pma_gis_geometry.php';
|
||||
*/
|
||||
abstract class PMA_GIS_GeomTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* test generateWkt method
|
||||
*
|
||||
* @param array $gis_data array of GIS data
|
||||
* @param int $index index
|
||||
* @param string $empty string to be insterted in place of missing values
|
||||
* @param string $wkt expected WKT
|
||||
*
|
||||
* @return void
|
||||
* @dataProvider providerForTestGenerateWkt
|
||||
*/
|
||||
public function testGenerateWkt($gis_data, $index, $empty, $wkt)
|
||||
{
|
||||
if ($empty == null) {
|
||||
$this->assertEquals($this->object->generateWkt($gis_data, $index), $wkt);
|
||||
} else {
|
||||
$this->assertEquals(
|
||||
$this->object->generateWkt($gis_data, $index, $empty),
|
||||
$wkt
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test generateParams method
|
||||
|
||||
125
test/libraries/PMA_bookmark_test.php
Normal file
125
test/libraries/PMA_bookmark_test.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for bookmark.lib.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_bookmark_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function setUp(){
|
||||
|
||||
if (! function_exists('PMA_getRelationsParam')) {
|
||||
function PMA_getRelationsParam()
|
||||
{
|
||||
$cfgRelation['bookmarkwork'] = true;
|
||||
return $cfgRelation;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('PMA_DBI_fetch_result')) {
|
||||
function PMA_DBI_fetch_result()
|
||||
{
|
||||
return array(
|
||||
'id' => 'id',
|
||||
'label' => 'label'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (! defined('PMA_DBI_QUERY_STORE')) {
|
||||
define('PMA_DBI_QUERY_STORE', 1);
|
||||
}
|
||||
|
||||
$GLOBALS['cfg']['Server']['user'] = 'root';
|
||||
$GLOBALS['cfg']['Server']['pmadb'] = 'phpmyadmin';
|
||||
$GLOBALS['cfg']['Server']['bookmarktable'] = 'pma_bookmark';
|
||||
$GLOBALS['server'] = 1;
|
||||
|
||||
require_once 'libraries/bookmark.lib.php';
|
||||
}
|
||||
/**
|
||||
* Test for PMA_Bookmark_getParams
|
||||
*/
|
||||
public function testPMA_Bookmark_getParams(){
|
||||
|
||||
$this->assertEquals(
|
||||
PMA_Bookmark_getParams(),
|
||||
array(
|
||||
'user' => 'root',
|
||||
'db' => 'phpmyadmin',
|
||||
'table'=> 'pma_bookmark'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_Bookmark_getList
|
||||
*/
|
||||
public function testPMA_Bookmark_getList(){
|
||||
$this->assertEquals(
|
||||
PMA_Bookmark_getList('phpmyadmin'),
|
||||
array(
|
||||
'id' => 'id (shared)',
|
||||
'label' => 'label (shared)'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_Bookmark_get
|
||||
*/
|
||||
public function testPMA_Bookmark_get(){
|
||||
if (! function_exists('PMA_DBI_fetch_value')) {
|
||||
function PMA_DBI_fetch_value()
|
||||
{
|
||||
return "SELECT query FROM `phpmyadmin`.`pma_bookmark` WHERE dbase = 'phpmyadmin' AND (user = 'root' OR user = '') AND `id` = 1";
|
||||
}
|
||||
}
|
||||
$this->assertEquals(
|
||||
PMA_Bookmark_get('phpmyadmin', '1'),
|
||||
"SELECT query FROM `phpmyadmin`.`pma_bookmark` WHERE dbase = 'phpmyadmin' AND (user = 'root' OR user = '') AND `id` = 1"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_Bookmark_save
|
||||
*/
|
||||
public function testPMA_Bookmark_save(){
|
||||
if (! function_exists('PMA_DBI_query')) {
|
||||
function PMA_DBI_query()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$this->assertEquals(
|
||||
PMA_Bookmark_save('phpmyadmin'),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_Bookmark_delete
|
||||
*/
|
||||
public function testPMA_Bookmark_delete(){
|
||||
if (! function_exists('PMA_DBI_try_query')) {
|
||||
function PMA_DBI_try_query()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$this->assertEquals(
|
||||
PMA_Bookmark_delete('phpmyadmin', '1'),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
155
test/libraries/PMA_build_html_for_db_test.php
Normal file
155
test/libraries/PMA_build_html_for_db_test.php
Normal file
@ -0,0 +1,155 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* tests for build_html_for_db.lib.php
|
||||
*
|
||||
* @package PhpMyAdmin-test
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include to test.
|
||||
*/
|
||||
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
require_once 'libraries/build_html_for_db.lib.php';
|
||||
require_once 'libraries/js_escape.lib.php';
|
||||
require_once 'libraries/Theme.class.php';
|
||||
|
||||
class PMA_build_html_for_db_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test for PMA_getColumnOrder
|
||||
*/
|
||||
public function testPMA_getColumnOrder(){
|
||||
|
||||
if (! function_exists('PMA_getServerCollation')) {
|
||||
function PMA_getServerCollation()
|
||||
{
|
||||
return 'footer';
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals(
|
||||
PMA_getColumnOrder(),
|
||||
array(
|
||||
'DEFAULT_COLLATION_NAME' => array(
|
||||
'disp_name' => __('Collation'),
|
||||
'description_function' => 'PMA_getCollationDescr',
|
||||
'format' => 'string',
|
||||
'footer' => 'footer'
|
||||
),
|
||||
'SCHEMA_TABLES' => array(
|
||||
'disp_name' => __('Tables'),
|
||||
'format' => 'number',
|
||||
'footer' => 0
|
||||
),
|
||||
'SCHEMA_TABLE_ROWS' => array(
|
||||
'disp_name' => __('Rows'),
|
||||
'format' => 'number',
|
||||
'footer' => 0
|
||||
),
|
||||
'SCHEMA_DATA_LENGTH' => array(
|
||||
'disp_name' => __('Data'),
|
||||
'format' => 'byte',
|
||||
'footer' => 0
|
||||
),
|
||||
'SCHEMA_INDEX_LENGTH' => array(
|
||||
'disp_name' => __('Indexes'),
|
||||
'format' => 'byte',
|
||||
'footer' => 0
|
||||
),
|
||||
'SCHEMA_LENGTH' => array(
|
||||
'disp_name' => __('Total'),
|
||||
'format' => 'byte',
|
||||
'footer' => 0
|
||||
),
|
||||
'SCHEMA_DATA_FREE' => array(
|
||||
'disp_name' => __('Overhead'),
|
||||
'format' => 'byte',
|
||||
'footer' => 0
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for PMA_buildHtmlForDb
|
||||
*
|
||||
* @param array $current
|
||||
* @param boolean $is_superuser
|
||||
* @param string $checkall
|
||||
* @param string $url_query
|
||||
* @param array $column_order
|
||||
* @param array $replication_types
|
||||
* @param array $replication_info
|
||||
* @param $output
|
||||
*
|
||||
* @dataProvider providerForTestPMA_buildHtmlForDb
|
||||
*/
|
||||
public function testPMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query,$column_order, $replication_types, $replication_info, $output){
|
||||
|
||||
if (! function_exists('PMA_is_system_schema')) {
|
||||
function PMA_is_system_schema()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (! function_exists('p')) {
|
||||
function p()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (! defined('PMA_DRIZZLE')) {
|
||||
define('PMA_DRIZZLE', false);
|
||||
}
|
||||
|
||||
$GLOBALS['cfg']['PropertiesIconic'] = true;
|
||||
$_SESSION['PMA_Theme'] = new PMA_Theme();
|
||||
$GLOBALS['pmaThemeImage'] = '';
|
||||
|
||||
$this->assertEquals(
|
||||
PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query,
|
||||
$column_order, $replication_types, $replication_info),
|
||||
$output
|
||||
);
|
||||
}
|
||||
|
||||
public function providerForTestPMA_buildHtmlForDb(){
|
||||
return array(
|
||||
array(
|
||||
array('SCHEMA_NAME' => 'pma'),
|
||||
true,
|
||||
'',
|
||||
'target=main.php',
|
||||
array(
|
||||
'SCHEMA_NAME' => 'pma',
|
||||
'footer' => 1,
|
||||
'format' => 'byte',
|
||||
'description_function' => 'onClick'
|
||||
),
|
||||
array(
|
||||
'SCHEMA_NAME' => 'pma',
|
||||
),
|
||||
array(
|
||||
'pma' => array(
|
||||
'status' => 'true',
|
||||
'Ignore_DB' => array(
|
||||
'pma' => 'pma'
|
||||
),
|
||||
)
|
||||
),
|
||||
array(
|
||||
0 => array(
|
||||
'SCHEMA_NAME' => 'pma',
|
||||
'footer' => 1,
|
||||
'format' => 'byte',
|
||||
'description_function' => 'onClick'
|
||||
),
|
||||
1 => '<td class="tool"><input type="checkbox" name="selected_dbs[]" class="checkall" title="pma" value="pma" /></td><td class="name"> <a onclick="if (window.parent.openDb && window.parent.openDb(\'pma\')) return false;" href="index.php?target=main.php&db=pma" title="Jump to database" target="_parent"> pma</a></td><td class="value"><dfn title="">pma</dfn></td><td class="tool" style="text-align: center;"><span class="nowrap"><img src="s_cancel.png" title="Not replicated" alt="Not replicated" /></span></td><td class="tool"><a onclick="if (window.parent.setDb) window.parent.setDb(\'`pma`\');" href="server_privileges.php?target=main.php&checkprivs=pma" title="Check privileges for database "pma"."> <span class="nowrap"><img src="s_rights.png" title="Check Privileges" alt="Check Privileges" /></span></a></td>'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/Theme.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_buildActionTitles_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_formatNumberByteDown_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_getFormattedMaximumUploadSize_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_getTitleForTarget_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
* Include to test.
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_localisedDateTimespan_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/Theme.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_showDocu_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
@ -14,7 +14,6 @@ const PMA_IS_WINDOWS = false;
|
||||
*/
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/Table.class.php';
|
||||
require_once 'libraries/database_interface.lib.php';
|
||||
require_once 'libraries/js_escape.lib.php';
|
||||
|
||||
class PMA_showMessage_test extends PHPUnit_Framework_TestCase
|
||||
@ -22,6 +21,10 @@ class PMA_showMessage_test extends PHPUnit_Framework_TestCase
|
||||
function setUp()
|
||||
{
|
||||
global $cfg;
|
||||
if (! defined('VERSION_CHECK_DEFAULT')) {
|
||||
define('VERSION_CHECK_DEFAULT', 1);
|
||||
}
|
||||
|
||||
include 'libraries/config.default.php';
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
require_once 'libraries/core.lib.php';
|
||||
require_once 'libraries/CommonFunctions.class.php';
|
||||
require_once 'libraries/Theme.class.php';
|
||||
require_once 'libraries/php-gettext/gettext.inc';
|
||||
|
||||
class PMA_showPHPDocu_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user