Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix code Static Analysis Warnings #587

Merged
merged 5 commits into from Aug 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 39 additions & 2 deletions test/classes/PMA_Advisor_test.php
Expand Up @@ -15,8 +15,20 @@
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/core.lib.php';

/**
* Tests behaviour of PMA_Advisor class
*
* @package PhpMyAdmin-test
*/
class Advisor_Test extends PHPUnit_Framework_TestCase
{

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setup()
{
$_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme');
Expand All @@ -39,6 +51,11 @@ public function testEscape($text, $expected)
$this->assertEquals(Advisor::escapePercent($text), $expected);
}

/**
* return of escape Strings
*
* @return array
*/
public function escapeStrings()
{
return array(
Expand All @@ -49,13 +66,23 @@ public function escapeStrings()
);
}

/**
* test for parseRulesFile
*
* @return void
*/
public function testParse()
{
$advisor = new Advisor();
$parseResult = $advisor->parseRulesFile();
$this->assertEquals($parseResult['errors'], array());
}


/**
* test for ADVISOR_bytime
*
* @return void
*/
public function testAdvisorBytime()
{
$result = ADVISOR_bytime(10, 2);
Expand All @@ -67,7 +94,12 @@ public function testAdvisorBytime()
$result = ADVISOR_bytime(0.003, 2);
$this->assertEquals("10.8 per hour", $result);
}


/**
* test for ADVISOR_timespanFormat
*
* @return void
*/
public function testAdvisorTimespanFormat()
{
$result = ADVISOR_timespanFormat(1200);
Expand Down Expand Up @@ -104,6 +136,11 @@ public function testAddRule($rule, $expected, $error)
}
}

/**
* rules Provider
*
* @return array
*/
public function rulesProvider()
{
return array(
Expand Down
90 changes: 90 additions & 0 deletions test/classes/PMA_Config_test.php
Expand Up @@ -18,6 +18,11 @@
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';

/**
* Tests behaviour of PMA_Config class
*
* @package PhpMyAdmin-test
*/
class PMA_ConfigTest extends PHPUnit_Framework_TestCase
{
/**
Expand Down Expand Up @@ -54,6 +59,11 @@ protected function tearDown()
{
}

/**
* Test for CheckSystem
*
* @return void
*/
public function testCheckSystem()
{
$this->object->checkSystem();
Expand All @@ -63,6 +73,11 @@ public function testCheckSystem()
$this->assertNotEmpty($this->object->get('PMA_THEME_GENERATION'));
}

/**
* Test for GetFontsizeForm
*
* @return void
*/
public function testGetFontsizeForm()
{
$this->assertContains(
Expand Down Expand Up @@ -125,6 +140,11 @@ public function testGetFontsizeForm()
$GLOBALS['PMA_Config']->set('fontsize', $fontsize);
}

/**
* Test for checkOutputCompression
*
* @return void
*/
public function testCheckOutputCompression()
{

Expand Down Expand Up @@ -173,6 +193,11 @@ public function testCheckClient($agent, $os, $browser = null, $version = null)
}
}

/**
* user Agent Provider
*
* @return array
*/
public function userAgentProvider()
{
return array(
Expand Down Expand Up @@ -268,6 +293,12 @@ public function userAgentProvider()

}


/**
* test for CheckGd2
*
* @return array
*/
public function testCheckGd2()
{
$prevIsGb2Val = $this->object->get('PMA_IS_GD2');
Expand Down Expand Up @@ -350,6 +381,12 @@ public function testCheckWebServer($server, $iis)
unset($_SERVER['SERVER_SOFTWARE']);
}


/**
* return server names
*
* @return array
*/
public function serverNames()
{
return array(
Expand All @@ -364,6 +401,12 @@ public function serverNames()
);
}


/**
* test for CheckWebServerOs
*
* @return array
*/
public function testCheckWebServerOs()
{
$this->object->checkWebServerOs();
Expand All @@ -389,6 +432,11 @@ public function testCheckWebServerOs()
}
}

/**
* test for CheckPhpVersion
*
* @return array
*/
public function testCheckPhpVersion()
{
$this->object->checkPhpVersion();
Expand Down Expand Up @@ -479,6 +527,11 @@ public function testLoadDefaults()
$this->assertFalse($this->object->error_config_default_file);
}

/**
* test for CheckConfigSource
*
* @return array
*/
public function testCheckConfigSource()
{
$this->object->setSource('unexisted.config.php');
Expand Down Expand Up @@ -531,6 +584,12 @@ public function testGetSetSource()
);
}


/**
* test for CheckPmaAbsoluteUriEmpty
*
* @return array
*/
public function testCheckPmaAbsoluteUriEmpty()
{
$this->object->set('PmaAbsoluteUri', '');
Expand Down Expand Up @@ -562,6 +621,11 @@ public function testCheckPmaAbsoluteUri($real, $expected)
$this->assertEquals($expected, $this->object->get('PmaAbsoluteUri'));
}

/**
* return absolute Uris
*
* @return array
*/
public function absoluteUris()
{
return array(
Expand Down Expand Up @@ -611,6 +675,11 @@ public function testCheckPmaAbsoluteUriScheme()
);
}

/**
* test for CheckCollationConnection
*
* @return array
*/
public function testCheckCollationConnection()
{
$_REQUEST['collation_connection'] = 'utf-8';
Expand All @@ -622,6 +691,11 @@ public function testCheckCollationConnection()
);
}

/**
* test for IsHttp
*
* @return array
*/
public function testIsHttps()
{
$this->object->set('is_https', null);
Expand All @@ -633,6 +707,11 @@ public function testIsHttps()
$this->assertTrue($this->object->isHttps());
}

/**
* test for DetectHttps
*
* @return array
*/
public function testDetectHttps()
{
unset($_SERVER['REQUEST_URI']);
Expand Down Expand Up @@ -757,6 +836,11 @@ public function testLoad($source, $result)
}
}

/**
* return of config Paths
*
* @return array
*/
public function configPaths()
{
return array(
Expand Down Expand Up @@ -952,6 +1036,12 @@ public function testSSLUri($original, $expected)
$this->assertEquals($expected, $this->object->getSSLUri());
}


/**
* return of ssl Uris
*
* @return array
*/
public function sslUris()
{
return array(
Expand Down
15 changes: 13 additions & 2 deletions test/classes/PMA_Table_test.php
Expand Up @@ -902,18 +902,29 @@ protected function setUp()
}

/**
* DataBasePMAMock Class
* Mock class for DataBasePMAMock
*
* @package PhpMyAdmin-test
*/
Class DataBasePMAMock
{
var $databases;
}

/**
* DataBasePMAMock Class
* Mock class for DataBaseMock
*
* @package PhpMyAdmin-test
*/
Class DataBaseMock
{
/**
* mock function to return table is existed
*
* @param string $name table name
*
* @return bool
*/
function exists($name)
{
return true;
Expand Down
2 changes: 1 addition & 1 deletion test/classes/PMA_Util_test.php
Expand Up @@ -116,7 +116,7 @@ public function testGetLatestVersion()
/**
* Test version to int conversion.
*
* @param string $version Version string
* @param string $version Version string
* @param int $numeric Integer matching version
*
* @return void
Expand Down
8 changes: 5 additions & 3 deletions test/libraries/PMA_FormDisplay_tpl_test.php
Expand Up @@ -292,7 +292,8 @@ public function testDisplayInput()

$this->assertTag(
PMA_getTagArray(
'<span class="field-comment-mark field-comment-warning" title="testComment">',
'<span class="field-comment-mark field-comment-warning" '
. 'title="testComment">',
array('content' => 'i')
),
$result
Expand Down Expand Up @@ -744,8 +745,9 @@ public function testAddJsValidate()

$this->assertEquals(
array(
'validateField(\'testID\', \'PMA_\\\';\', true, [\'\\\\r\\\\n\\\\\\\'' .
'<scrIpt></\\\' + \\\'script>\'])',
'validateField(\'testID\', \'PMA_\\\';\', true, '
. '[\'\\\\r\\\\n\\\\\\\''
. '<scrIpt></\\\' + \\\'script>\'])',
'validateField(\'testID\', \'PMA_\', true)'
),
$js
Expand Down
6 changes: 3 additions & 3 deletions test/libraries/PMA_relation_cleanup_test.php
Expand Up @@ -73,7 +73,7 @@ public function redefineRelation()
*
* @return void
*/
public function testPMA_relationsCleanupColumn()
public function testPMARelationsCleanupColumn()
{
$db = "PMA";
$table = "PMA_bookmark";
Expand Down Expand Up @@ -153,7 +153,7 @@ public function testPMA_relationsCleanupColumn()
*
* @return void
*/
public function testPMA_relationsCleanupTable()
public function testPMARelationsCleanupTable()
{
$db = "PMA";
$table = "PMA_bookmark";
Expand Down Expand Up @@ -231,7 +231,7 @@ public function testPMA_relationsCleanupTable()
*
* @return void
*/
public function testPMA_relationsCleanupDatabase()
public function testPMARelationsCleanupDatabase()
{
$db = "PMA";
$this->redefineRelation();
Expand Down