public function properties() { $r = new Runner('/var/www', 'dev'); $r->mapApplication('/debug', (new \xp\scriptlet\WebApplication('debug'))->withScriptlet(self::$debugScriptlet->getName())->withConfig('res://user')->withArguments(['Debugging', 'today'])); ob_start(); $_REQUEST = []; $content = $r->run('/debug'); $_REQUEST = []; $content = ob_get_contents(); ob_end_clean(); preg_match('#<h2>(.+)</h2>#', $content, $config); $this->assertEquals('util.CompositeProperties', $config[1], 'config'); }
case 'cli-server': if (is_file($_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'])) { return FALSE; } header('HTTP/1.0 500 Internal Server Error'); $_SERVER['SCRIPT_URL'] = substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], '?#')); $_SERVER['SERVER_PROFILE'] = getenv('SERVER_PROFILE'); define('STDIN', fopen('php://stdin', 'rb')); define('STDOUT', fopen('php://stdout', 'wb')); define('STDERR', fopen('php://stderr', 'wb')); break; default: header('HTTP/1.0 500 Internal Server Error'); } ini_set('error_prepend_string', '<xmp>'); ini_set('error_append_string', '</xmp>'); ini_set('html_errors', 0); // Bootstrap if (!(include __DIR__ . DIRECTORY_SEPARATOR . 'lang.base.php')) { trigger_error('[bootstrap] Cannot determine boot class path', E_USER_ERROR); exit(0x3d); } // Set up class path $paths = array(); $scan = explode(PATH_SEPARATOR . PATH_SEPARATOR, get_include_path()); foreach (explode(PATH_SEPARATOR, $scan[0]) as $path) { $paths[] = '~' === $path[0] ? str_replace('~', $webroot, $path) : $path; } bootstrap(scanpath($paths, $webroot) . (isset($scan[1]) ? $scan[1] : '')); exit(\xp\scriptlet\Runner::main(array($webroot, $configd, $_SERVER['SERVER_PROFILE'], $_SERVER['SCRIPT_URL'])));
public function callingMain() { $temp = System::tempDir(); // Create web.ini in system's temp dir $ini = new \io\File($temp, 'web.ini'); $ini->open(FILE_MODE_WRITE); $ini->write("[app]\n" . "mappings=\"/:welcome\"\n" . "[app::welcome]\n" . "class=undefined\n" . "[app::welcome@dev]\n" . "class=\"" . self::$welcomeScriptlet->getName() . "\"\n"); $ini->close(); // Run ob_start(); Runner::main(array($temp, $temp, 'dev', '/')); $content = ob_get_contents(); ob_end_clean(); $ini->unlink(); // Assert $this->assertEquals('<h1>Welcome, we are open</h1>', $content); }