/** * xmlのmapのnameからurlを返す * @param string $test_file テストファイルパス * @param string $map_name テストファイルにひも付くアプリケーションXMLのMAP名 * @return string */ public static function map_url($test_file, $map_name) { $args = func_get_args(); array_shift($args); array_shift($args); if (!empty(self::$current_map_test_file)) { $test_file = self::$current_map_test_file; } if (!isset(self::$maps[$test_file]) && preg_match("/^(.+)\\/([^\\/]+)_test\\.php\$/", $test_file, $match)) { list(, $dir, $file) = $match; $dir = str_replace(self::path(), "", $dir); if (substr($dir, 0, 1) == "/") { $dir = substr($dir, 1); } if (substr($dir, -1) == "/") { $dir = substr($dir, 0, -1); } $target_file = App::path($dir . "/" . $file . ".php"); if (is_file($target_file)) { $parse_app = Flow::parse_app($target_file); foreach ($parse_app['apps'] as $app) { if ($app['type'] == 'handle') { foreach ($app['maps'] as $p => $c) { $count = 0; if (!empty($p)) { $p = substr(preg_replace_callback("/([^\\\\])(\\(.*?[^\\\\]\\))/", create_function('$m', 'return $m[1]."%s";'), " " . $p, -1, $count), 1); } if (!empty($c['name'])) { self::$maps[$test_file][$c['name']][$count] = $p; } } } } } } if (!isset(self::$maps[$test_file])) { throw new InvalidArgumentException($test_file . " is not app"); } if (!isset(self::$maps[$test_file][$map_name]) || !isset(self::$maps[$test_file][$map_name][sizeof($args)])) { throw new InvalidArgumentException($test_file . "[" . $map_name . "](" . sizeof($args) . ") not found"); } return App::url(vsprintf(self::$maps[$test_file][$map_name][sizeof($args)], $args)); }