Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Applying patches by ADMad updating HtmlHelper and adding test. Adding…

… missing properties in test case. Preventing bleed through in test case. Fixes #6490

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8220 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 68d333d0883428748457e1cca0e5bd937ee0085e 1 parent d2a6be2
@davidpersson davidpersson authored
View
9 cake/libs/view/helpers/html.php
@@ -316,7 +316,7 @@ function link($title, $url = null, $htmlAttributes = array(), $confirmMessage =
/**
* Creates a link element for CSS stylesheets.
*
- * @param mixed $path The name of a CSS style sheet or an array containing names of
+ * @param mixed $path The name of a CSS style sheet or an array containing names of
* CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot
* of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css.
* @param string $rel Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported.
@@ -437,10 +437,11 @@ function image($path, $options = array()) {
} elseif ($path[0] === '/') {
$path = $this->webroot($path);
} elseif (strpos($path, '://') === false) {
+ $path = $this->webroot(IMAGES_URL . $path);
+
if ((Configure::read('Asset.timestamp') == true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
- $path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . IMAGES_URL . $path));
+ $path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . $path));
}
- $path = $this->webroot(IMAGES_URL . $path);
}
if (!isset($options['alt'])) {
@@ -639,4 +640,4 @@ function __nestedListItem($items, $attributes, $itemAttributes, $tag) {
return $out;
}
}
-?>
+?>
View
58 cake/tests/cases/libs/view/helpers/html.test.php
@@ -56,12 +56,33 @@ class TheHtmlTestController extends Controller {
*/
class HtmlHelperTest extends CakeTestCase {
/**
- * html property
+ * Html property
*
- * @var mixed null
+ * @var object
* @access public
*/
- var $html = null;
+ var $Html = null;
+/**
+ * Backup of app encoding configuration setting
+ *
+ * @var string
+ * @access protected
+ */
+ var $_appEncoding;
+/**
+ * Backup of asset configuration settings
+ *
+ * @var string
+ * @access protected
+ */
+ var $_asset;
+/**
+ * Backup of debug configuration setting
+ *
+ * @var integer
+ * @access protected
+ */
+ var $_debug;
/**
* setUp method
*
@@ -73,6 +94,8 @@ function setUp() {
$view =& new View(new TheHtmlTestController());
ClassRegistry::addObject('view', $view);
$this->_appEncoding = Configure::read('App.encoding');
+ $this->_asset = Configure::read('Asset');
+ $this->_debug = Configure::read('debug');
}
/**
* tearDown method
@@ -82,6 +105,8 @@ function setUp() {
*/
function tearDown() {
Configure::write('App.encoding', $this->_appEncoding);
+ Configure::write('Asset', $this->_asset);
+ Configure::write('debug', $this->_debug);
ClassRegistry::flush();
}
/**
@@ -254,14 +279,34 @@ function testImageTag() {
$result = $this->Html->image('cake.icon.gif');
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
- $back = Configure::read('debug');
Configure::write('debug', 0);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->image('cake.icon.gif');
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
+ }
+/**
+ * Tests creation of an image tag using a theme and asset timestamping
+ *
+ * @access public
+ * @return void
+ * @link https://trac.cakephp.org/ticket/6490
+ */
+ function testImageTagWithTheme() {
+ $file = WWW_ROOT . 'themed' . DS . 'default' . DS . 'img' . DS . 'cake.power.gif';
+ $message = "File '{$file}' not present. %s";
+ $this->skipUnless(file_exists($file), $message);
- Configure::write('debug', $back);
+ Configure::write('Asset.timestamp', true);
+ Configure::write('debug', 1);
+ $this->Html->themeWeb = 'themed/default/';
+
+ $result = $this->Html->image('cake.power.gif');
+ $this->assertTags($result, array(
+ 'img' => array(
+ 'src' => 'preg:/themed\/default\/img\/cake\.power\.gif\?\d+/',
+ 'alt' => ''
+ )));
}
/**
* testStyle method
@@ -331,7 +376,6 @@ function testCssLink() {
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected);
- $debug = Configure::read('debug');
Configure::write('debug', 0);
$result = $this->Html->css('cake.generic');
@@ -357,8 +401,6 @@ function testCssLink() {
$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?/';
$this->assertTags($result, $expected);
$this->Html->webroot = $webroot;
-
- Configure::write('debug', $debug);
}
/**
* testCharsetTag method
Please sign in to comment.
Something went wrong with that request. Please try again.