예제 #1
0
 /**
  * @covers MapUtil::get
  */
 public function testGet()
 {
     $map = array("name" => "user name", "age" => 24, "city" => array("Montpellier", "Toulouse", 34000, "Paris"), "phone" => "047839749347");
     $actual = \MapUtil::get($map, "age");
     $excepted = 24;
     $this->assertEquals($excepted, $actual);
     $actual = \MapUtil::get($map, "city");
     $excepted = array("Montpellier", "Toulouse", 34000, "Paris");
     $this->assertEquals($excepted, $actual);
     $actual = \MapUtil::get($map, "email", "*****@*****.**");
     $excepted = "*****@*****.**";
     $this->assertEquals($excepted, $actual);
 }
예제 #2
0
 /**
  * Get the path info, which is everything that follows the application
  * node in the URL. (without query info).
  * The returned pathinfo will not start or end with '/'.
  *
  * @return String
  */
 public static function getPathInfo()
 {
     $appRoot = self::getAppRoot();
     // Get the URL path (everything until the '?')
     $path = MapUtil::get($_SERVER, 'CONTEXT_PREFIX');
     // CONTEXT_PREFIX is aparently new to apache 2.3.13
     // If undefined, fall back to previous method. This one, though, is known
     // to have a problem when the URL is root. ('/').
     if ($path === null || $path === "") {
         $path = isset($_SERVER['SCRIPT_URL']) ? $_SERVER['SCRIPT_URL'] : $_SERVER['PHP_SELF'];
     }
     $pathInfo = substr($path, strlen($appRoot));
     if (beginsWith($pathInfo, '/')) {
         $pathInfo = substr($pathInfo, 1);
     }
     if (endsWith($pathInfo, '/')) {
         $pathInfo = substr($pathInfo, 0, -1);
     }
     return $pathInfo;
 }