mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
parent
22373868bb
commit
e61f636bc7
2 changed files with 21 additions and 3 deletions
|
@ -361,7 +361,14 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Html->image('test.gif?one=two&three=four');
|
$result = $this->Html->image('test.gif?one=two&three=four');
|
||||||
$this->assertTags($result, array('img' => array('src' => 'img/test.gif?one=two&three=four', 'alt' => '')));
|
$this->assertTags($result, array('img' => array('src' => 'img/test.gif?one=two&three=four', 'alt' => '')));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that image() works with fullBase and a webroot not equal to /
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testImageWithFullBase() {
|
||||||
$result = $this->Html->image('test.gif', array('fullBase' => true));
|
$result = $this->Html->image('test.gif', array('fullBase' => true));
|
||||||
$here = $this->Html->url('/', true);
|
$here = $this->Html->url('/', true);
|
||||||
$this->assertTags($result, array('img' => array('src' => $here . 'img/test.gif', 'alt' => '')));
|
$this->assertTags($result, array('img' => array('src' => $here . 'img/test.gif', 'alt' => '')));
|
||||||
|
@ -369,6 +376,15 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
$result = $this->Html->image('sub/test.gif', array('fullBase' => true));
|
$result = $this->Html->image('sub/test.gif', array('fullBase' => true));
|
||||||
$here = $this->Html->url('/', true);
|
$here = $this->Html->url('/', true);
|
||||||
$this->assertTags($result, array('img' => array('src' => $here . 'img/sub/test.gif', 'alt' => '')));
|
$this->assertTags($result, array('img' => array('src' => $here . 'img/sub/test.gif', 'alt' => '')));
|
||||||
|
|
||||||
|
$request = $this->Html->request;
|
||||||
|
$request->webroot = '/myproject/';
|
||||||
|
$request->base = '/myproject';
|
||||||
|
Router::setRequestInfo($request);
|
||||||
|
|
||||||
|
$result = $this->Html->image('sub/test.gif', array('fullBase' => true));
|
||||||
|
$here = $this->Html->url('/', true);
|
||||||
|
$this->assertTags($result, array('img' => array('src' => $here . 'img/sub/test.gif', 'alt' => '')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -313,10 +313,12 @@ class Helper extends Object {
|
||||||
$path = h($this->assetTimestamp($this->webroot($path)));
|
$path = h($this->assetTimestamp($this->webroot($path)));
|
||||||
|
|
||||||
if (!empty($options['fullBase'])) {
|
if (!empty($options['fullBase'])) {
|
||||||
if ($path[0] == '/') {
|
$base = $this->url('/', true);
|
||||||
$path = substr($path, 1);
|
$len = strlen($this->request->webroot);
|
||||||
|
if ($len) {
|
||||||
|
$base = substr($base, 0, -$len);
|
||||||
}
|
}
|
||||||
$path = $this->url('/', true) . $path;
|
$path = $base . $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue