/** * Adds a dynamic stylesheet to the response object. * * The first argument is an internal URI. * The helper automatically adds the sf_format to the internal URI, so you don't have to. * * @see sfResponse->addStylesheet() */ function use_dynamic_stylesheet($css, $position = '', $options = array()) { $options['raw_name'] = true; return use_stylesheet(_dynamic_path($css, 'css'), $position, $options); }
'use_stylesheet() accepts an array of options as a third parameter'); use_stylesheet('style', '', array('absolute' => true)); $t->is(get_stylesheets(), '<link rel="stylesheet" type="text/css" media="screen" href="http://localhost/css/style.css" />'."\n", 'use_stylesheet() accepts an array of options as a third parameter'); use_stylesheet('style'); use_stylesheet('style2'); $t->is(get_stylesheets(), '<link rel="stylesheet" type="text/css" media="screen" href="/css/style.css" />'."\n".'<link rel="stylesheet" type="text/css" media="screen" href="/css/style2.css" />'."\n", 'get_stylesheets() returns all the stylesheets previously added by use_stylesheet()'); // _dynamic_path() $t->diag('_dynamic_path()'); $t->is(_dynamic_path('module/action', 'js'), 'module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL'); $t->is(_dynamic_path('module/action?key=value', 'js'), 'module/action?key=value&sf_format=js', '_dynamic_path() converts an internal URI to a URL'); $t->is(_dynamic_path('module/action', 'js', true), '/module/action?sf_format=js', '_dynamic_path() converts an internal URI to a URL'); // dynamic_javascript_include_tag() $t->diag('dynamic_javascript_include_tag()'); $t->is(dynamic_javascript_include_tag('module/action'), '<script type="text/javascript" src="module/action?sf_format=js"></script>'."\n", 'dynamic_javascript_include_tag() returns a tag relative to the given action'); $t->is(dynamic_javascript_include_tag('module/action', true), '<script type="text/javascript" src="/module/action?sf_format=js"></script>'."\n", 'dynamic_javascript_include_tag() takes an absolute boolean as its second argument'); $t->is(dynamic_javascript_include_tag('module/action', true, array('class' => 'foo')), '<script type="text/javascript" src="/module/action?sf_format=js" class="foo"></script>'."\n", 'dynamic_javascript_include_tag() takes an array of HTML attributes as its third argument'); $context->response = new myResponse($context->getEventDispatcher()); // use_dynamic_javascript() $t->diag('use_dynamic_javascript()'); use_dynamic_javascript('module/action'); $t->is(get_javascripts(), '<script type="text/javascript" src="module/action?sf_format=js"></script>'."\n", 'use_dynamic_javascript() register a dynamic javascript in the response'