phpmyadmin/test/libraries/core/PMA_getLinks_test.php
Michal Čihař e56949f160 Use package name PhpMyAdmin
Needed to match phpdoc rules as package name must begin with upper case.
2011-10-25 10:13:17 +02:00

72 lines
2.3 KiB
PHP

<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_getPHPDocLink, PMA_linkURL, PMA_includeJS from libraries/core.lib.php
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/core.lib.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
class PMA_getLinks_test extends PHPUnit_Framework_TestCase
{
function setUp()
{
$_SESSION[' PMA_token '] = 'token';
$GLOBALS['lang'] = 'en';
$GLOBALS['server'] = 99;
$GLOBALS['cfg']['ServerDefault'] = 0;
}
public function testPMA_getPHPDocLink()
{
$lang = _pgettext('PHP documentation language', 'en');
$this->assertEquals(
PMA_getPHPDocLink('function'),
'./url.php?url=http%3A%2F%2Fphp.net%2Fmanual%2F'
. $lang . '%2Ffunction&amp;server=99&amp;lang=en&amp;token=token'
);
}
public function providerLinkURL(){
return array(
array('http://wiki.phpmyadmin.net', './url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net&amp;server=99&amp;lang=en&amp;token=token'),
array('https://wiki.phpmyadmin.net', './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net&amp;server=99&amp;lang=en&amp;token=token'),
array('wiki.phpmyadmin.net', 'wiki.phpmyadmin.net'),
array('index.php?db=phpmyadmin', 'index.php?db=phpmyadmin')
);
}
/**
* @dataProvider providerLinkURL
*/
public function testPMA_linkURL($link, $url){
$this->assertEquals(PMA_linkURL($link), $url);
}
public function testPMA_includeJS()
{
$filename = "common.js";
$mod = 0;
if (file_exists('./js/'.$filename)) {
$mod = filemtime('./js/'.$filename);
} else {
$this->fail("JS file doesn't exists.");
}
$this->assertEquals(PMA_includeJS($filename), '<script src="./js/'.$filename.'?ts='.$mod.'" type="text/javascript"></script>'. "\n");
$filename = '?file.js';
//$this->assertEquals(PMA_includeJS($filename), '<script src="./js/?file.js" type="text/javascript"></script>\n');
$this->assertEquals(PMA_includeJS($filename), '<script src="./js/'.$filename.'" type="text/javascript"></script>'."\n");
//$this->assertFalse(PMA_includeJS(null));
}
}