Skip to content
This repository
Browse code

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
David Persson authored July 04, 2009
9  cake/libs/view/helpers/html.php
@@ -316,7 +316,7 @@ function link($title, $url = null, $htmlAttributes = array(), $confirmMessage =
316 316
 /**
317 317
  * Creates a link element for CSS stylesheets.
318 318
  *
319  
- * @param mixed $path The name of a CSS style sheet or an array containing names of 
  319
+ * @param mixed $path The name of a CSS style sheet or an array containing names of
320 320
  *   CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot
321 321
  *   of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css.
322 322
  * @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()) {
437 437
 		} elseif ($path[0] === '/') {
438 438
 			$path = $this->webroot($path);
439 439
 		} elseif (strpos($path, '://') === false) {
  440
+			$path = $this->webroot(IMAGES_URL . $path);
  441
+
440 442
 			if ((Configure::read('Asset.timestamp') == true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
441  
-				$path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . IMAGES_URL . $path));
  443
+				$path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . $path));
442 444
 			}
443  
-			$path = $this->webroot(IMAGES_URL . $path);
444 445
 		}
445 446
 
446 447
 		if (!isset($options['alt'])) {
@@ -639,4 +640,4 @@ function __nestedListItem($items, $attributes, $itemAttributes, $tag) {
639 640
 		return $out;
640 641
 	}
641 642
 }
642  
-?>
  643
+?>
58  cake/tests/cases/libs/view/helpers/html.test.php
@@ -56,12 +56,33 @@ class TheHtmlTestController extends Controller {
56 56
  */
57 57
 class HtmlHelperTest extends CakeTestCase {
58 58
 /**
59  
- * html property
  59
+ * Html property
60 60
  *
61  
- * @var mixed null
  61
+ * @var object
62 62
  * @access public
63 63
  */
64  
-	var $html = null;
  64
+	var $Html = null;
  65
+/**
  66
+ * Backup of app encoding configuration setting
  67
+ *
  68
+ * @var string
  69
+ * @access protected
  70
+ */
  71
+	var $_appEncoding;
  72
+/**
  73
+ * Backup of asset configuration settings
  74
+ *
  75
+ * @var string
  76
+ * @access protected
  77
+ */
  78
+	var $_asset;
  79
+/**
  80
+ * Backup of debug configuration setting
  81
+ *
  82
+ * @var integer
  83
+ * @access protected
  84
+ */
  85
+	var $_debug;
65 86
 /**
66 87
  * setUp method
67 88
  *
@@ -73,6 +94,8 @@ function setUp() {
73 94
 		$view =& new View(new TheHtmlTestController());
74 95
 		ClassRegistry::addObject('view', $view);
75 96
 		$this->_appEncoding = Configure::read('App.encoding');
  97
+		$this->_asset = Configure::read('Asset');
  98
+		$this->_debug = Configure::read('debug');
76 99
 	}
77 100
 /**
78 101
  * tearDown method
@@ -82,6 +105,8 @@ function setUp() {
82 105
  */
83 106
 	function tearDown() {
84 107
 		Configure::write('App.encoding', $this->_appEncoding);
  108
+		Configure::write('Asset', $this->_asset);
  109
+		Configure::write('debug', $this->_debug);
85 110
 		ClassRegistry::flush();
86 111
 	}
87 112
 /**
@@ -254,14 +279,34 @@ function testImageTag() {
254 279
 		$result = $this->Html->image('cake.icon.gif');
255 280
 		$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
256 281
 
257  
-		$back = Configure::read('debug');
258 282
 		Configure::write('debug', 0);
259 283
 		Configure::write('Asset.timestamp', 'force');
260 284
 
261 285
 		$result = $this->Html->image('cake.icon.gif');
262 286
 		$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
  287
+	}
  288
+/**
  289
+ * Tests creation of an image tag using a theme and asset timestamping
  290
+ *
  291
+ * @access public
  292
+ * @return void
  293
+ * @link https://trac.cakephp.org/ticket/6490
  294
+ */
  295
+	function testImageTagWithTheme() {
  296
+		$file = WWW_ROOT . 'themed' . DS . 'default' . DS . 'img' . DS . 'cake.power.gif';
  297
+		$message = "File '{$file}' not present. %s";
  298
+		$this->skipUnless(file_exists($file), $message);
263 299
 
264  
-		Configure::write('debug', $back);
  300
+		Configure::write('Asset.timestamp', true);
  301
+		Configure::write('debug', 1);
  302
+		$this->Html->themeWeb = 'themed/default/';
  303
+
  304
+		$result = $this->Html->image('cake.power.gif');
  305
+		$this->assertTags($result, array(
  306
+			'img' => array(
  307
+				'src' => 'preg:/themed\/default\/img\/cake\.power\.gif\?\d+/',
  308
+				'alt' => ''
  309
+		)));
265 310
 	}
266 311
 /**
267 312
  * testStyle method
@@ -331,7 +376,6 @@ function testCssLink() {
331 376
 		$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
332 377
 		$this->assertTags($result, $expected);
333 378
 
334  
-		$debug = Configure::read('debug');
335 379
 		Configure::write('debug', 0);
336 380
 
337 381
 		$result = $this->Html->css('cake.generic');
@@ -357,8 +401,6 @@ function testCssLink() {
357 401
 		$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?/';
358 402
 		$this->assertTags($result, $expected);
359 403
 		$this->Html->webroot = $webroot;
360  
-
361  
-		Configure::write('debug', $debug);
362 404
 	}
363 405
 /**
364 406
  * testCharsetTag method

0 notes on commit 68d333d

Please sign in to comment.
Something went wrong with that request. Please try again.