Added test for relative path using app asset configuration

This commit is contained in:
Juan Basso 2013-08-03 11:04:52 -04:00
parent db6d0a748b
commit cda1a1e6c9

View file

@ -400,6 +400,9 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->image('http://google.com/logo.gif');
$this->assertTags($result, array('img' => array('src' => 'http://google.com/logo.gif', 'alt' => '')));
$result = $this->Html->image('//google.com/logo.gif');
$this->assertTags($result, array('img' => array('src' => '//google.com/logo.gif', 'alt' => '')));
$result = $this->Html->image(array('controller' => 'test', 'action' => 'view', 1, 'ext' => 'gif'));
$this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => '')));
@ -417,6 +420,12 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->image('test.gif', array('pathPrefix' => '//cakephp.org/assets/img/'));
$this->assertTags($result, array('img' => array('src' => '//cakephp.org/assets/img/test.gif', 'alt' => '')));
$previousConfig = Configure::read('App.imageBaseUrl');
Configure::write('App.imageBaseUrl', '//cdn.cakephp.org/img/');
$result = $this->Html->image('test.gif');
$this->assertTags($result, array('img' => array('src' => '//cdn.cakephp.org/img/test.gif', 'alt' => '')));
Configure::write('App.imageBaseUrl', $previousConfig);
}
/**
@ -610,6 +619,13 @@ class HtmlHelperTest extends CakeTestCase {
$expected['link']['href'] = 'http://cakephp.org/assets/css/cake.generic.css';
$this->assertTags($result, $expected);
$previousConfig = Configure::read('App.cssBaseUrl');
Configure::write('App.cssBaseUrl', '//cdn.cakephp.org/css/');
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = '//cdn.cakephp.org/css/cake.generic.css';
$this->assertTags($result, $expected);
Configure::write('App.cssBaseUrl', $previousConfig);
Configure::write('Asset.filter.css', 'css.php');
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*ccss\/cake\.generic\.css/';
@ -955,6 +971,15 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$previousConfig = Configure::read('App.jsBaseUrl');
Configure::write('App.jsBaseUrl', '//cdn.cakephp.org/js/');
$result = $this->Html->script('foo4');
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => '//cdn.cakephp.org/js/foo4.js')
);
$this->assertTags($result, $expected);
Configure::write('App.jsBaseUrl', $previousConfig);
$result = $this->Html->script('foo');
$this->assertNull($result, 'Script returned upon duplicate inclusion %s');