Exemplo n.º 1
0
 public function testGetUrl()
 {
     $helper = new AssetsHelper();
     $this->assertEquals('http://example.com/foo.js', $helper->getUrl('http://example.com/foo.js'), '->getUrl() does nothing if an absolute URL is given');
     $helper = new AssetsHelper();
     $this->assertEquals('/foo.js', $helper->getUrl('foo.js'), '->getUrl() appends a / on relative paths');
     $this->assertEquals('/foo.js', $helper->getUrl('/foo.js'), '->getUrl() does nothing on absolute paths');
     $helper = new AssetsHelper('/foo');
     $this->assertEquals('/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() appends the basePath on relative paths');
     $this->assertEquals('/foo.js', $helper->getUrl('/foo.js'), '->getUrl() does not append the basePath on absolute paths');
     $helper = new AssetsHelper(null, 'http://assets.example.com/');
     $this->assertEquals('http://assets.example.com/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL');
     $this->assertEquals('http://assets.example.com/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL');
     $helper = new AssetsHelper(null, 'http://www.example.com/foo');
     $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL with a path');
     $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL with a path');
     $helper = new AssetsHelper('/foo', 'http://www.example.com/');
     $this->assertEquals('http://www.example.com/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL and the base path if defined');
     $this->assertEquals('http://www.example.com/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL but not the base path on absolute paths');
     $helper = new AssetsHelper('/bar', 'http://www.example.com/foo');
     $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('foo.js'), '->getUrl() prepends the base URL and the base path if defined');
     $this->assertEquals('http://www.example.com/foo/foo.js', $helper->getUrl('/foo.js'), '->getUrl() prepends the base URL but not the base path on absolute paths');
     $helper = new AssetsHelper('/bar', 'http://www.example.com/foo', 'abcd');
     $this->assertEquals('http://www.example.com/foo/foo.js?abcd', $helper->getUrl('foo.js'), '->getUrl() appends the version if defined');
 }
Exemplo n.º 2
0
 public function testMagicToString()
 {
     $assetHelper = new AssetsHelper();
     $assetHelper->setBaseURLs('');
     $helper = new StylesheetsHelper($assetHelper);
     $helper->add('foo', array('media' => 'ba>'));
     $this->assertEquals('<link href="/foo" rel="stylesheet" type="text/css" media="ba&gt;" />' . "\n", $helper->__toString(), '->__toString() converts the stylesheet configuration to HTML');
 }
Exemplo n.º 3
0
 public function testMagicToString()
 {
     $assetHelper = new AssetsHelper();
     $assetHelper->setBaseURLs('');
     $helper = new JavascriptsHelper($assetHelper);
     $helper->add('foo', array('class' => 'ba>'));
     $this->assertEquals('<script type="text/javascript" src="/foo" class="ba&gt;"></script>' . "\n", $helper->__toString(), '->__toString() converts the JavaScript configuration to HTML');
 }
Exemplo n.º 4
0
 public function testGetUrlLeavesProtocolRelativePathsUntouched()
 {
     $helper = new AssetsHelper(null, 'http://foo.com');
     $this->assertEquals('//bar.com/asset', $helper->getUrl('//bar.com/asset'));
 }
Exemplo n.º 5
0
 /**
  * Constructor.
  *
  * @param Request      $request  A Request instance
  * @param string|array $baseURLs The domain URL or an array of domain URLs
  * @param string       $version  The version
  * @param array        $packages Asset packages indexed by name
  */
 public function __construct(Request $request, $baseURLs = array(), $version = null, $packages = array())
 {
     parent::__construct($request->getBasePath(), $baseURLs, $version, $packages);
 }