2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for PMA_getPHPDocLink, PMA_linkURL, PMA_includeJS from libraries/core.lib.php
6 * @package phpMyAdmin-test
12 require_once 'libraries/core.lib.php';
13 require_once 'libraries/url_generating.lib.php';
14 require_once 'libraries/php-gettext/gettext.inc';
16 class PMA_getLinks_test
extends PHPUnit_Framework_TestCase
20 $_SESSION[' PMA_token '] = 'token';
21 $GLOBALS['lang'] = 'en';
22 $GLOBALS['server'] = 99;
23 $GLOBALS['cfg']['ServerDefault'] = 0;
26 public function testPMA_getPHPDocLink()
28 $lang = _pgettext('PHP documentation language', 'en');
29 $this->assertEquals(PMA_getPHPDocLink('function'), 'http://php.net/manual/' . $lang . '/function');
32 public function providerLinkURL(){
34 array('http://wiki.phpmyadmin.net', './url.php?url=http%3A%2F%2Fwiki.phpmyadmin.net&server=99&lang=en&token=token'),
35 array('https://wiki.phpmyadmin.net', './url.php?url=https%3A%2F%2Fwiki.phpmyadmin.net&server=99&lang=en&token=token'),
36 array('wiki.phpmyadmin.net', 'wiki.phpmyadmin.net'),
37 array('index.php?db=phpmyadmin', 'index.php?db=phpmyadmin')
42 * @dataProvider providerLinkURL
44 public function testPMA_linkURL($link, $url){
45 $this->assertEquals(PMA_linkURL($link), $url);
48 public function testPMA_includeJS()
50 $filename = "common.js";
53 if (file_exists('./js/'.$filename)) {
54 $mod = filemtime('./js/'.$filename);
57 $this->fail("JS file doesn't exists.");
59 $this->assertEquals(PMA_includeJS($filename), '<script src="./js/'.$filename.'?ts='.$mod.'" type="text/javascript"></script>'. "\n");
61 $filename = '?file.js';
62 //$this->assertEquals(PMA_includeJS($filename), '<script src="./js/?file.js" type="text/javascript"></script>\n');
63 $this->assertEquals(PMA_includeJS($filename), '<script src="./js/'.$filename.'" type="text/javascript"></script>'."\n");
65 //$this->assertFalse(PMA_includeJS(null));