/usr/share/php/tests/Horde_Util/Horde/Util/UtilTest.php is in php-horde-util 2.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | <?php
/**
* @author Jan Schneider <jan@horde.org>
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @category Horde
* @package Util
* @subpackage UnitTests
*/
class Horde_Util_UtilTest extends PHPUnit_Framework_TestCase
{
public function testGetPathInfo()
{
$this->assertEquals('', Horde_Util::getPathInfo());
$_SERVER['SERVER_SOFTWARE'] = '';
$_SERVER['PATH_INFO'] = '';
$this->assertEquals('', Horde_Util::getPathInfo());
$_SERVER['PATH_INFO'] = '/foo/bar';
$this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
$_SERVER['SERVER_SOFTWARE'] = 'lighttpd/1.4.26';
$_SERVER['PATH_INFO'] = '';
$_SERVER['REQUEST_URI'] = '/horde/path.php';
$_SERVER['SCRIPT_NAME'] = '/horde/path.php';
$this->assertEquals('', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/path.php?baz';
$_SERVER['QUERY_STRING'] = 'baz';
$this->assertEquals('', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/path.php/foo/bar';
$_SERVER['SCRIPT_NAME'] = '/horde/path.php';
$_SERVER['QUERY_STRING'] = '';
$this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/path.php/foo/bar?baz';
$_SERVER['QUERY_STRING'] = 'baz';
$this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/foo/bar?baz';
$this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/';
$_SERVER['SCRIPT_NAME'] = '/horde/index.php';
$this->assertEquals('', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/index.php';
$_SERVER['SCRIPT_NAME'] = '/horde/index.php';
$_SERVER['QUERY_STRING'] = '';
$this->assertEquals('', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/index.php?baz';
$_SERVER['QUERY_STRING'] = 'baz';
$this->assertEquals('', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/index.php/foo/bar';
$_SERVER['SCRIPT_NAME'] = '/horde/index.php';
$_SERVER['QUERY_STRING'] = '';
$this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/horde/index.php/foo/bar?baz';
$_SERVER['QUERY_STRING'] = 'baz';
$this->assertEquals('/foo/bar', Horde_Util::getPathInfo());
$_SERVER['REQUEST_URI'] = '/test/42?id=42';
$_SERVER['SCRIPT_NAME'] = '/test/index.php';
$_SERVER['QUERY_STRING'] = 'id=42&id=42';
$this->assertEquals('/42', Horde_Util::getPathInfo());
}
public function testDispelMagicQuotes()
{
Horde_Util_Test::setMagicQuotes(false);
$vars = $expected = array('foobar', 'foo\bar', 'foo\\bar', 'foo\"bar');
foreach ($vars as $key => $var) {
$this->assertEquals($expected[$key], Horde_Util_Test::dispelMagicQuotes($var));
$this->assertEquals($expected[$key], Horde_Util_Test::dispelMagicQuotes($var));
}
foreach ($vars as $key => $var) {
$var = array($var);
$this->assertEquals(array($expected[$key]), Horde_Util_Test::dispelMagicQuotes($var));
$this->assertEquals(array($expected[$key]), Horde_Util_Test::dispelMagicQuotes($var));
}
Horde_Util_Test::setMagicQuotes(true);
$vars = array('foobar', 'foo\bar', 'foo\\\\bar', 'foo\"bar');
$expected = array('foobar', 'foobar', 'foo\bar', 'foo"bar');
foreach ($vars as $key => $var) {
$this->assertEquals($expected[$key], Horde_Util_Test::dispelMagicQuotes($var));
$this->assertEquals($expected[$key], Horde_Util_Test::dispelMagicQuotes($var));
}
foreach ($vars as $key => $var) {
$var = array($var);
$this->assertEquals(array($expected[$key]), Horde_Util_Test::dispelMagicQuotes($var));
$this->assertEquals(array($expected[$key]), Horde_Util_Test::dispelMagicQuotes($var));
}
}
}
/**
* @internal
*/
class Horde_Util_Test extends Horde_Util
{
static public function setMagicQuotes($set)
{
self::$_magicquotes = $set;
}
}
|