Пример #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 current fetching scripts.
  *
  * @return void
  */
 public function testFetchScripts()
 {
     $expected = 'script block';
     $this->View->start(LayoutHelper::SCRIPT_BLOCK);
     echo $expected;
     $this->View->end();
     $expectedBottom = 'script bottom block';
     $this->View->start(LayoutHelper::SCRIPT_BLOCK_BOTTOM);
     echo $expectedBottom;
     $this->View->end();
     $actual = $this->Layout->fetchScripts();
     $this->assertRegExp('/' . $expected . '/', $actual);
     $this->assertRegExp('/' . $expectedBottom . '/', $actual);
     $this->assertSame($expected, $this->View->Blocks->get('script'));
     $this->assertSame($expectedBottom, $this->View->Blocks->get('script_bottom'));
 }
Пример #4
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'));
 }
Пример #5
0
 /**
  * @expectedException \Cake\View\Exception\MissingElementException
  */
 public function testElementNotFind()
 {
     $this->View->element('TestPlugin.not_found');
 }
Пример #6
0
 /**
  * Constructor hook method.
  *
  * @param array $config
  * @return void
  */
 public function initialize(array $config)
 {
     parent::initialize($config);
     $this->_path = $this->_View->getPath();
 }