/** * @test * @profile */ public function testDispatch() { split_time('reset'); Rest_Test_Unit_Case_Resource_Foo::serve('resource/foo'); split_time('Invoke Rest_Test_Unit_Case_Resource_Foo::serve(resource/foo)'); Http_Scriptlet_Context::push(new Http_Scriptlet_Context(Environment::uriComponents())); split_time('Initialize Components\\Http_Scriptlet_Context'); $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json')); split_time("Invoke Uri::valueOf({$uri})"); ob_start(); split_time('reset'); Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET); split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)"); $result = ob_get_clean(); assertEquals(json_encode(true), $result); split_time('reset'); $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json')); $uri->setQueryParam('log', 'false'); split_time("Invoke Uri::valueOf({$uri})"); ob_start(); split_time('reset'); Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET); split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)"); $result = ob_get_clean(); assertEquals(json_encode(false), $result); }
/** * @param string $image_ * * @return \Components\Uri */ public static function uriForPath($image_) { $extension = Io::fileExtension($image_); $key = md5($image_); Cache::set($key, $image_); return Environment::uriComponents('ui', 'image', "{$key}.{$extension}"); }
/** * @see \Components\Media_Storage::uriByScheme() \Components\Media_Storage::uriByScheme() */ public function uriByScheme($scheme_, $id_, $category_ = null) { if (@is_file(Environment::pathResource("{$this->store->path}/{$scheme_}/{$category_}/{$id_}"))) { return "{$this->store->uri}/{$scheme_}/{$category_}/{$id_}"; } // TODO (CSH) Http_Scriptlet_Router return Environment::uriComponents(sprintf('media/image/%1$s%2$s', \str\encodeBase64Url(serialize(array($this->store->path, $id_, $category_, $scheme_))), substr($id_, strrpos($id_, '.')))); }