public function testUrlBaseRelativePath() { $relative = 'path/to/file'; $baseUrl = 'http://domain.com/sub/'; $defaultBaseUrl = 'http://localhost/project/'; \Curry_URL::setDefaultBaseUrl($defaultBaseUrl); // No base specified (should use default) $url = new \Curry_URL($relative); $this->assertEquals('/project/' . $relative, $url->getRelative()); $this->assertEquals($defaultBaseUrl . $relative, $url->getAbsolute()); // Base specified on instance $url = new \Curry_URL('path/to/file'); $url->setBaseUrl($baseUrl); $this->assertEquals('/sub/' . $relative, $url->getRelative()); $this->assertEquals($baseUrl . $relative, $url->getAbsolute()); }
/** * Initializes CurryCms using the specified configuration. * * @param string|array|null $config Path to configuration file, array with configuration options or null for no configuration. * @param float|null $startTime Time when initialization was started (use microtime(true)), if not specified the current time will be used. * @param bool|null $initAutoloader Attempt to initialize vendor/autoload.php */ public static function init($config, $startTime = null, $initAutoloader = null) { self::$startTime = $startTime === null ? microtime(true) : $startTime; if (get_magic_quotes_gpc()) { throw new Exception('magic quotes gpc is enabled, please disable!'); } // Initialize autoloader? if ($initAutoloader === null) { $initAutoloader = spl_autoload_functions(); $initAutoloader = $initAutoloader === false || !count($initAutoloader); } if ($initAutoloader) { $autoload = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; if (!file_exists($autoload)) { throw new Exception('curry/vendor/autoload.php not found, make sure composer dependencies have been installed.'); } self::$autoloader = (require_once $autoload); } // load configuration self::$config = new Zend_Config(self::getConfig($config)); // add project path to autoloader if ($initAutoloader) { $projectInclude = Curry_Util::path(self::$config->curry->projectPath, 'include'); self::$autoloader->add('', $projectInclude); set_include_path($projectInclude . PATH_SEPARATOR . get_include_path()); } // trigger hook self::triggerHook('Curry_Core::preInit'); // try to use utf-8 locale setlocale(LC_ALL, 'en_US.UTF-8', 'en_US.UTF8', 'UTF-8', 'UTF8'); // umask if (self::$config->curry->umask) { umask(self::$config->curry->umask); } // init self::initErrorHandling(); self::initLogging(); self::initPropel(); self::initCache(); self::initEncoding(); Curry_URL::setDefaultBaseUrl(self::$config->curry->baseUrl); Curry_URL::setDefaultSecret(self::$config->curry->secret); self::triggerHook('Curry_Core::postInit'); register_shutdown_function(array(__CLASS__, 'shutdown')); }