protected function getServerInfo() { static $scheme_ports = array('http' => 80, 'https' => 443, 'telnet' => 23); WebserverDefaults::setServerURL(); $url = WebserverDefaults::getServerURL(); if (!empty($url)) { $info = parse_url($url); if (isset($info['scheme']) && array_key_exists($info['scheme'], $scheme_ports) && !isset($info['port'])) { $info['port'] = $scheme_ports[$info['scheme']]; } } else { $info = array(); } return $info; }
/** * A support method which sets the URL (with scheme and authority as per RFC3986) to the sample test site, which' location is by default based on the currently running script. * * @param string $auth_str The optional userinfo (cf. RFC3986 section 3.2) part of the URI. * @param string $path Either the optional complete URL to the test site or the (relative to the starting script) path to the test sample site root directory. Default: './site/' * @return string The URL as currently configured. * @access public */ static function setServerUrl($auth_str = null, $path = 'site/') { global $_SERVER; if (empty(self::$default_server_url)) { $url = parse_url(strtr($path, '\\', '/')); // keep path? when it's a relative path and assumed relative to the running script. $path_is_relative = !empty($url['path']) && empty($url['host']) && $url['path'][0] != '/' && substr($path, 0, strlen($url['path'])) == $url['path']; // else: path is assumed to have specified a (more or less) fully qualified URL; do NOT append it to the default location as well! if (!empty($_SERVER['HTTP_HOST']) && !empty($_SERVER['SCRIPT_NAME'])) { $dflt = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on" ? "https" : "http"; $dflt .= '://' . $_SERVER['HTTP_HOST'] . (!empty($_SERVER['SERVER_PORT']) ? ':' . $_SERVER['SERVER_PORT'] : ''); $dflt .= strtr(str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']), '\\', '/') . ($path_is_relative ? $path : ''); } else { $dflt = 'http://www.lastcraft.com/test/'; } $url = self::completeURL($path_is_relative ? $dflt : $path, $dflt, $auth_str); self::$default_server_url = $url; } else { $url = self::$default_server_url; } return $url; }
<?php // $Id$ require_once dirname(__FILE__) . '/../default_server.php'; require_once dirname(__FILE__) . '/../remote.php'; require_once dirname(__FILE__) . '/../reporter.php'; // nasty hack: ensure the commanline i processed before anything else in here so that the default server URI can indeed be set by the user: $ignore_me = new DefaultReporter(); // The following URL will depend on your own installation. $test_url = str_replace('site/', 'visual_test.php', WebserverDefaults::getServerUrl()); if (isset($_SERVER['SCRIPT_URI'])) { $base_uri = $_SERVER['SCRIPT_URI']; $test_url = str_replace('remote_test.php', 'visual_test.php', $base_uri); } elseif (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF'])) { $base_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $test_url = str_replace('remote_test.php', 'visual_test.php', $base_uri); } $test = new TestSuite('Remote tests'); $test->add(new RemoteTestCase($test_url . '?xml=yes', $test_url . '?xml=yes&dry=yes')); if (SimpleReporter::inCli()) { exit($test->run(new NoPassesReporter(new TextReporter())) ? 0 : 1); } $test->run(new NoPassesReporter(new HtmlReporter()));
/** * A support method which delivers the URL (with scheme and authority as per RFC3986) to the targeted test site, * where the default test site is assumed to be the URL as provided by @see WebserverDefaults::getServerUrl(), * which can be overridden by specifying a different URL through the setServerUrl() method. * * @param string $auth_str The optional userinfo (cf. RFC3986 section 3.2) part of the URI. * @param string $path The optional relative path to the previously configured 'server URL'. * @return string The URL as currently configured. * @access public */ function getServerUrl($auth_str = null, $path = null) { if (empty($this->server_url)) { $url = WebserverDefaults::getServerURL($auth_str); $this->server_url = $url; } else { $url = $this->server_url; } return WebserverDefaults::completeURL($path, $url, $auth_str); }
/** * Get the user-specified default server URL. * @return string THe default server URL (FQDN + test root directory). */ function getServerUrl() { WebserverDefaults::setServerUrl(null, $this->server_uri); return WebserverDefaults::getServerUrl(); }