|
@@ -64,14 +64,15 @@ class HtmlHelperTest extends TestCase
|
|
|
public function setUp()
|
|
public function setUp()
|
|
|
{
|
|
{
|
|
|
parent::setUp();
|
|
parent::setUp();
|
|
|
|
|
+
|
|
|
|
|
+ $request = new ServerRequest([
|
|
|
|
|
+ 'webroot' => '',
|
|
|
|
|
+ ]);
|
|
|
$this->View = $this->getMockBuilder('Cake\View\View')
|
|
$this->View = $this->getMockBuilder('Cake\View\View')
|
|
|
->setMethods(['append'])
|
|
->setMethods(['append'])
|
|
|
|
|
+ ->setConstructorArgs([$request])
|
|
|
->getMock();
|
|
->getMock();
|
|
|
$this->Html = new HtmlHelper($this->View);
|
|
$this->Html = new HtmlHelper($this->View);
|
|
|
- $this->Html->request = new ServerRequest([
|
|
|
|
|
- 'webroot' => '',
|
|
|
|
|
- ]);
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request;
|
|
|
|
|
|
|
|
|
|
Plugin::load(['TestTheme']);
|
|
Plugin::load(['TestTheme']);
|
|
|
static::setAppNamespace();
|
|
static::setAppNamespace();
|
|
@@ -117,7 +118,7 @@ class HtmlHelperTest extends TestCase
|
|
|
{
|
|
{
|
|
|
Router::connect('/:controller/:action/*');
|
|
Router::connect('/:controller/:action/*');
|
|
|
|
|
|
|
|
- $this->Html->request = $this->Html->request->withAttribute('webroot', '');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', ''));
|
|
|
|
|
|
|
|
$result = $this->Html->link('/home');
|
|
$result = $this->Html->link('/home');
|
|
|
$expected = ['a' => ['href' => '/home'], 'preg:/\/home/', '/a'];
|
|
$expected = ['a' => ['href' => '/home'], 'preg:/\/home/', '/a'];
|
|
@@ -381,10 +382,10 @@ class HtmlHelperTest extends TestCase
|
|
|
*/
|
|
*/
|
|
|
public function testImageDataUriBaseDir()
|
|
public function testImageDataUriBaseDir()
|
|
|
{
|
|
{
|
|
|
- $request = $this->Html->request
|
|
|
|
|
|
|
+ $request = $this->View->getRequest()
|
|
|
->withAttribute('base', 'subdir')
|
|
->withAttribute('base', 'subdir')
|
|
|
->withAttribute('webroot', 'subdir/');
|
|
->withAttribute('webroot', 'subdir/');
|
|
|
- $this->Html->Url->request = $this->Html->request = $request;
|
|
|
|
|
|
|
+ $this->View->setRequest($request);
|
|
|
Router::pushRequest($request);
|
|
Router::pushRequest($request);
|
|
|
|
|
|
|
|
$data = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4' .
|
|
$data = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4' .
|
|
@@ -464,9 +465,10 @@ class HtmlHelperTest extends TestCase
|
|
|
$expected = ['img' => ['src' => $here . 'img/sub/test.gif', 'alt' => '']];
|
|
$expected = ['img' => ['src' => $here . 'img/sub/test.gif', 'alt' => '']];
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()
|
|
|
->withAttribute('webroot', '/myproject/')
|
|
->withAttribute('webroot', '/myproject/')
|
|
|
- ->withAttribute('base', '/myproject');
|
|
|
|
|
|
|
+ ->withAttribute('base', '/myproject')
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
$result = $this->Html->image('sub/test.gif', ['fullBase' => true]);
|
|
$result = $this->Html->image('sub/test.gif', ['fullBase' => true]);
|
|
|
$here = $this->Html->Url->build('/', true);
|
|
$here = $this->Html->Url->build('/', true);
|
|
@@ -483,7 +485,7 @@ class HtmlHelperTest extends TestCase
|
|
|
{
|
|
{
|
|
|
Configure::write('Asset.timestamp', 'force');
|
|
Configure::write('Asset.timestamp', 'force');
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/'));
|
|
|
$result = $this->Html->image('cake.icon.png');
|
|
$result = $this->Html->image('cake.icon.png');
|
|
|
$expected = ['img' => ['src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '']];
|
|
$expected = ['img' => ['src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '']];
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
@@ -495,7 +497,7 @@ class HtmlHelperTest extends TestCase
|
|
|
$expected = ['img' => ['src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '']];
|
|
$expected = ['img' => ['src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '']];
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/longer/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/longer/'));
|
|
|
$result = $this->Html->image('cake.icon.png');
|
|
$result = $this->Html->image('cake.icon.png');
|
|
|
$expected = [
|
|
$expected = [
|
|
|
'img' => ['src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.png\?[0-9]+/', 'alt' => '']
|
|
'img' => ['src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.png\?[0-9]+/', 'alt' => '']
|
|
@@ -518,7 +520,7 @@ class HtmlHelperTest extends TestCase
|
|
|
Configure::write('Asset.timestamp', true);
|
|
Configure::write('Asset.timestamp', true);
|
|
|
Configure::write('debug', true);
|
|
Configure::write('debug', true);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/'));
|
|
|
$this->Html->Url->getView()->setTheme('TestTheme');
|
|
$this->Html->Url->getView()->setTheme('TestTheme');
|
|
|
$result = $this->Html->image('__cake_test_image.gif');
|
|
$result = $this->Html->image('__cake_test_image.gif');
|
|
|
$expected = [
|
|
$expected = [
|
|
@@ -529,7 +531,7 @@ class HtmlHelperTest extends TestCase
|
|
|
];
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/'));
|
|
|
$result = $this->Html->image('__cake_test_image.gif');
|
|
$result = $this->Html->image('__cake_test_image.gif');
|
|
|
$expected = [
|
|
$expected = [
|
|
|
'img' => [
|
|
'img' => [
|
|
@@ -769,12 +771,12 @@ class HtmlHelperTest extends TestCase
|
|
|
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
|
|
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/'));
|
|
|
$result = $this->Html->css('cake.generic', ['once' => false]);
|
|
$result = $this->Html->css('cake.generic', ['once' => false]);
|
|
|
$expected['link']['href'] = 'preg:/\/testing\/css\/cake\.generic\.css\?[0-9]+/';
|
|
$expected['link']['href'] = 'preg:/\/testing\/css\/cake\.generic\.css\?[0-9]+/';
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/longer/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/longer/'));
|
|
|
$result = $this->Html->css('cake.generic', ['once' => false]);
|
|
$result = $this->Html->css('cake.generic', ['once' => false]);
|
|
|
$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?[0-9]+/';
|
|
$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?[0-9]+/';
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
@@ -812,12 +814,12 @@ class HtmlHelperTest extends TestCase
|
|
|
$expected['link']['href'] = 'preg:/.*test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/';
|
|
$expected['link']['href'] = 'preg:/.*test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/';
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/'));
|
|
|
$result = $this->Html->css('TestPlugin.test_plugin_asset', ['once' => false]);
|
|
$result = $this->Html->css('TestPlugin.test_plugin_asset', ['once' => false]);
|
|
|
$expected['link']['href'] = 'preg:/\/testing\/test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/';
|
|
$expected['link']['href'] = 'preg:/\/testing\/test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/';
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/longer/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/longer/'));
|
|
|
$result = $this->Html->css('TestPlugin.test_plugin_asset', ['once' => false]);
|
|
$result = $this->Html->css('TestPlugin.test_plugin_asset', ['once' => false]);
|
|
|
$expected['link']['href'] = 'preg:/\/testing\/longer\/test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/';
|
|
$expected['link']['href'] = 'preg:/\/testing\/longer\/test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/';
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
@@ -1127,7 +1129,7 @@ class HtmlHelperTest extends TestCase
|
|
|
$testfile = WWW_ROOT . '/test_theme/js/__test_js.js';
|
|
$testfile = WWW_ROOT . '/test_theme/js/__test_js.js';
|
|
|
$File = new File($testfile, true);
|
|
$File = new File($testfile, true);
|
|
|
|
|
|
|
|
- $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/'));
|
|
|
$this->Html->Url->getView()->setTheme('TestTheme');
|
|
$this->Html->Url->getView()->setTheme('TestTheme');
|
|
|
$result = $this->Html->script('__test_js.js');
|
|
$result = $this->Html->script('__test_js.js');
|
|
|
$expected = [
|
|
$expected = [
|
|
@@ -1800,7 +1802,7 @@ class HtmlHelperTest extends TestCase
|
|
|
];
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->request = $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/'));
|
|
|
$result = $this->Html->meta('icon');
|
|
$result = $this->Html->meta('icon');
|
|
|
$expected = [
|
|
$expected = [
|
|
|
'link' => ['href' => '/testing/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'icon'],
|
|
'link' => ['href' => '/testing/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'icon'],
|
|
@@ -1832,7 +1834,7 @@ class HtmlHelperTest extends TestCase
|
|
|
];
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
|
|
- $this->Html->request = $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/testing/');
|
|
|
|
|
|
|
+ $this->View->setRequest($this->View->getRequest()->withAttribute('webroot', '/testing/'));
|
|
|
$result = $this->Html->meta('icon');
|
|
$result = $this->Html->meta('icon');
|
|
|
$expected = [
|
|
$expected = [
|
|
|
'link' => ['href' => '/testing/test_theme/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'icon'],
|
|
'link' => ['href' => '/testing/test_theme/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'icon'],
|