示例#1
0
 /**
  * Test include scripts.
  *
  * @return void
  */
 public function testScript()
 {
     $this->Html->script(['cake.js', 'base.js'], ['block' => true]);
     $this->assertEmpty($this->View->fetch('css'));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $this->Html->script('assets/js/admin/test-app.js', ['block' => true]);
     $expected = ['script' => ['src' => 'http://localhost/assets/js/admin/test-app.js']];
     $this->assertHtml($expected, $this->View->fetch('script'));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $this->Html->script(['assets/js/scripts.js', 'assets/js/scripts.js'], ['block' => 'once']);
     $expected = ['script' => ['src' => 'http://localhost/assets/js/scripts.js']];
     $this->assertHtml($expected, $this->View->fetch('once'));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $this->Html->script(['assets/build/js/jquery.min.js', 'assets/build/js/bootstrap.min.js', 'assets/build/js/no-file.js'], ['block' => 'union']);
     $expected = [['script' => ['src' => 'preg:/.*assets\\/build\\/js\\/jquery\\.min\\.js/']], '/script', ['script' => ['src' => 'preg:/.*assets\\/build\\/js\\/bootstrap\\.min\\.js/']], '/script'];
     $this->assertHtml($expected, $this->View->fetch('union'));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     Configure::write('debug', true);
     Configure::write('Asset.timestamp', true);
     $this->Html->script(['TestPlugin:assets/js/scripts.js'], ['block' => 'time']);
     $expected = ['script' => ['src' => 'preg:/.*js\\/scripts\\.js\\?[0-9]+/']];
     $this->assertHtml($expected, $this->View->fetch('time'));
     Configure::write('Asset.timestamp', false);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $actual = $this->Html->script(['TestPlugin:assets/js/admin/test-app.js'], ['block' => false]);
     $expected = ['script' => ['src' => 'http://localhost/Plugins/TestPlugin/assets/js/admin/test-app.js']];
     $this->assertHtml($expected, $actual);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $googleJQuery = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
     $actual = $this->Html->script($googleJQuery, ['block' => false]);
     $expected = ['script' => ['src' => $googleJQuery]];
     $this->assertHtml($expected, $actual);
 }
示例#2
0
 /**
  * Test include font awesome.
  *
  * @return void
  */
 public function testFontAwesome()
 {
     $expected = ['link' => ['rel' => 'stylesheet', 'href' => 'http://localhost/assets/build/css/font-awesome.min.css']];
     $class = $this->Assets->fontAwesome();
     $this->assertHtml($expected, $this->View->fetch('css'));
     $this->assertInstanceOf('Union\\Core\\View\\Helper\\AssetsHelper', $class);
 }
示例#3
0
 /**
  * Test addd meta rows.
  *
  * @return void
  */
 public function testMeta()
 {
     $expected = ['<meta charset="utf-8"/>', '<title>Page title</title>', '<meta name="viewport" content="width=device-width, initial-scale=1.0">'];
     $output = $this->Document->meta($expected);
     $expected = implode($this->Document->eol, $expected) . $this->Document->eol;
     $this->assertSame($expected, $output);
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $expected = ['<meta charset="utf-8"/>', '<title>Page title on block</title>', '<meta name="viewport" content="width=device-width, initial-scale=1.0">'];
     $this->assertNull($this->Document->meta($expected, 'meta'));
     $expected = implode($this->Document->eol, $expected) . $this->Document->eol;
     $this->assertSame($expected, $this->View->fetch('meta'));
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $expected = ['<meta charset="utf-8"/>', '<title>Page title on block</title>', '<meta name="viewport" content="width=device-width, initial-scale=1.0">', '<meta http-equiv="Content-Language" content="en">'];
     $expected = implode($this->Document->eol, $expected) . $this->Document->eol;
     $this->Document->meta(['<meta http-equiv="Content-Language" content="en">'], 'meta');
     $this->assertSame($expected, $this->View->fetch('meta'));
 }