Exemple #1
0
 public function testSetGetBaseURLs()
 {
     $helper = new AssetsHelper();
     $helper->setBaseURLs('http://www.example.com/');
     $this->assertEquals($helper->getBaseURLs(), array('http://www.example.com'), '->setBaseURLs() removes the / at the of an absolute base path');
     $helper->setBaseURLs(array('http://www1.example.com/', 'http://www2.example.com/'));
     $URLs = array();
     for ($i = 0; $i < 20; $i++) {
         $URLs[] = $helper->getBaseURL($i);
     }
     $URLs = array_values(array_unique($URLs));
     sort($URLs);
     $this->assertEquals($URLs, array('http://www1.example.com', 'http://www2.example.com'), '->getBaseURL() returns a random base URL if several are given');
     $helper->setBaseURLs('');
     $this->assertEquals($helper->getBaseURL(1), '', '->getBaseURL() returns an empty string if no base URL exist');
 }
 public function testMagicToString()
 {
     $assetHelper = new AssetsHelper();
     $assetHelper->setBaseURLs('');
     $helper = new StylesheetsHelper($assetHelper);
     $helper->add('foo', array('media' => 'ba>'));
     $this->assertEquals($helper->__toString(), '<link href="/foo" rel="stylesheet" type="text/css" media="ba&gt;" />' . "\n", '->__toString() converts the stylesheet configuration to HTML');
 }
 public function testMagicToString()
 {
     $assetHelper = new AssetsHelper();
     $assetHelper->setBaseURLs('');
     $helper = new JavascriptsHelper($assetHelper);
     $helper->add('foo', array('class' => 'ba>'));
     $this->assertEquals($helper->__toString(), '<script type="text/javascript" src="/foo" class="ba&gt;"></script>' . "\n", '->__toString() converts the JavaScript configuration to HTML');
 }
$t->is($helper->getBasePath(), '/foo/', '->setBasePath() prepends a / if needed');
$helper->setBasePath('/foo');
$t->is($helper->getBasePath(), '/foo/', '->setBasePath() appends a / is needed');
$helper->setBasePath('');
$t->is($helper->getBasePath(), '/', '->setBasePath() returns / if no base path is defined');
$helper->setBasePath('0');
$t->is($helper->getBasePath(), '/0/', '->setBasePath() returns /0/ if 0 is given');
// ->getVersion() ->getVersion()
$t->diag('->getVersion() ->getVersion()');
$helper = new AssetsHelper();
$helper->setVersion('foo');
$t->is($helper->getVersion(), 'foo', '->setVersion() sets the version');
// ->setBaseURLs() ->getBaseURLs()
$t->diag('->setBaseURLs() ->getBaseURLs()');
$helper = new AssetsHelper();
$helper->setBaseURLs('http://www.example.com/');
$t->is($helper->getBaseURLs(), array('http://www.example.com'), '->setBaseURLs() removes the / at the of an absolute base path');
$helper->setBaseURLs(array('http://www1.example.com/', 'http://www2.example.com/'));
$URLs = array();
for ($i = 0; $i < 20; $i++) {
    $URLs[] = $helper->getBaseURL($i);
}
$URLs = array_values(array_unique($URLs));
sort($URLs);
$t->is($URLs, array('http://www1.example.com', 'http://www2.example.com'), '->getBaseURL() returns a random base URL if several are given');
$helper->setBaseURLs('');
$t->is($helper->getBaseURL(1), '', '->getBaseURL() returns an empty string if no base URL exist');
// ->getUrl()
$t->diag('->getUrl()');
$helper = new AssetsHelper();
$t->is($helper->getUrl('http://example.com/foo.js'), 'http://example.com/foo.js', '->getUrl() does nothing if an absolute URL is given');