コード例 #1
0
// ->getBasePath() ->setBasePath()
$t->diag('->getBasePath() ->setBasePath()');
$helper = new AssetsHelper();
$helper->setBasePath('foo/');
$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');
コード例 #2
0
ファイル: AssetsTest.php プロジェクト: CodingFabian/symfony
 public function testGetSetVersion()
 {
     $helper = new AssetsHelper();
     $helper->setVersion('foo');
     $this->assertEquals($helper->getVersion(), 'foo', '->setVersion() sets the version');
 }