mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 08:13:58 +01:00 
			
		
		
		
	Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
		
							parent
							
								
									5a580df460
								
							
						
					
					
						commit
						235a541597
					
				
					 793 changed files with 60746 additions and 23753 deletions
				
			
		|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * HtmlHelperTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * | ||||
|  * Licensed under The MIT License | ||||
|  * For full copyright and license information, please see the LICENSE.txt | ||||
|  * Redistributions of files must retain the above copyright notice | ||||
|  * | ||||
|  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  * @since         CakePHP(tm) v 1.2.0.4206 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Controller', 'Controller'); | ||||
|  | @ -24,6 +23,7 @@ App::uses('HtmlHelper', 'View/Helper'); | |||
| App::uses('FormHelper', 'View/Helper'); | ||||
| App::uses('ClassRegistry', 'Utility'); | ||||
| App::uses('Folder', 'Utility'); | ||||
| App::uses('CakePlugin', 'Core'); | ||||
| 
 | ||||
| if (!defined('FULL_BASE_URL')) { | ||||
| 	define('FULL_BASE_URL', 'http://cakephp.org'); | ||||
|  | @ -39,14 +39,14 @@ class TheHtmlTestController extends Controller { | |||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'TheTest' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'TheTest'; | ||||
| 
 | ||||
| /** | ||||
|  * uses property | ||||
|  * | ||||
|  * @var mixed null | ||||
|  * @var mixed | ||||
|  */ | ||||
| 	public $uses = null; | ||||
| } | ||||
|  | @ -209,12 +209,20 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		Router::reload(); | ||||
| 
 | ||||
| 		$result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true)); | ||||
| 		$expected = array('a' => array('href' => FULL_BASE_URL . '/posts'), 'Posts', '/a'); | ||||
| 		$expected = array('a' => array('href' => Router::fullBaseUrl() . '/posts'), 'Posts', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?')); | ||||
| 		$expected = array( | ||||
| 			'a' => array('href' => '/home', 'onclick' => 'return confirm('Are you sure you want to do this?');'), | ||||
| 			'a' => array('href' => '/home', 'onclick' => 'if (confirm("Are you sure you want to do this?")) { return true; } return false;'), | ||||
| 			'Home', | ||||
| 			'/a' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('Home', '/home', array('escape' => false, 'confirm' => 'Confirm\'s "nightmares"')); | ||||
| 		$expected = array( | ||||
| 			'a' => array('href' => '/home', 'onclick' => 'if (confirm("Confirm's \"nightmares\"")) { return true; } return false;'), | ||||
| 			'Home', | ||||
| 			'/a' | ||||
| 		); | ||||
|  | @ -290,6 +298,17 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('Next >', '#', array( | ||||
| 			'title' => 'Next >', | ||||
| 			'escapeTitle' => false | ||||
| 		)); | ||||
| 		$expected = array( | ||||
| 			'a' => array('href' => '#', 'title' => 'Next >'), | ||||
| 			'Next >', | ||||
| 			'/a' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('Original size', array( | ||||
| 			'controller' => 'images', 'action' => 'view', 3, '?' => array('height' => 100, 'width' => 200) | ||||
| 		)); | ||||
|  | @ -310,6 +329,17 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link($this->Html->image('test.gif'), '#', array( | ||||
| 			'title' => 'hey "howdy"', | ||||
| 			'escapeTitle' => false | ||||
| 		)); | ||||
| 		$expected = array( | ||||
| 			'a' => array('href' => '#', 'title' => 'hey "howdy"'), | ||||
| 			'img' => array('src' => 'img/test.gif', 'alt' => ''), | ||||
| 			'/a' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->image('test.gif', array('url' => '#')); | ||||
| 		$expected = array( | ||||
| 			'a' => array('href' => '#'), | ||||
|  | @ -319,8 +349,8 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link($this->Html->image('../favicon.ico'), '#', array('escape' => false)); | ||||
|  		$expected = array( | ||||
|  			'a' => array('href' => '#'), | ||||
| 		$expected = array( | ||||
| 			'a' => array('href' => '#'), | ||||
| 			'img' => array('src' => 'img/../favicon.ico', 'alt' => ''), | ||||
| 			'/a' | ||||
| 		); | ||||
|  | @ -337,6 +367,30 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$result = $this->Html->link('http://www.example.org?param1=value1¶m2=value2'); | ||||
| 		$expected = array('a' => array('href' => 'http://www.example.org?param1=value1&param2=value2'), 'http://www.example.org?param1=value1&param2=value2', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('alert', 'javascript:alert(\'cakephp\');'); | ||||
| 		$expected = array('a' => array('href' => 'javascript:alert('cakephp');'), 'alert', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('write me', 'mailto:example@cakephp.org'); | ||||
| 		$expected = array('a' => array('href' => 'mailto:example@cakephp.org'), 'write me', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('call me on 0123465-798', 'tel:0123465-798'); | ||||
| 		$expected = array('a' => array('href' => 'tel:0123465-798'), 'call me on 0123465-798', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('text me on 0123465-798', 'sms:0123465-798'); | ||||
| 		$expected = array('a' => array('href' => 'sms:0123465-798'), 'text me on 0123465-798', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('say hello to 0123465-798', 'sms:0123465-798?body=hello there'); | ||||
| 		$expected = array('a' => array('href' => 'sms:0123465-798?body=hello there'), 'say hello to 0123465-798', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->link('say hello to 0123465-798', 'sms:0123465-798?body=hello "cakephp"'); | ||||
| 		$expected = array('a' => array('href' => 'sms:0123465-798?body=hello "cakephp"'), 'say hello to 0123465-798', '/a'); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -353,14 +407,54 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$result = $this->Html->image('http://google.com/logo.gif'); | ||||
| 		$this->assertTags($result, array('img' => array('src' => 'http://google.com/logo.gif', 'alt' => ''))); | ||||
| 
 | ||||
| 		$result = $this->Html->image('//google.com/logo.gif'); | ||||
| 		$this->assertTags($result, array('img' => array('src' => '//google.com/logo.gif', 'alt' => ''))); | ||||
| 
 | ||||
| 		$result = $this->Html->image(array('controller' => 'test', 'action' => 'view', 1, 'ext' => 'gif')); | ||||
| 		$this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => ''))); | ||||
| 
 | ||||
| 		$result = $this->Html->image('/test/view/1.gif'); | ||||
| 		$this->assertTags($result, array('img' => array('src' => '/test/view/1.gif', 'alt' => ''))); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test image() with query strings. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testImageQueryString() { | ||||
| 		$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' => ''))); | ||||
| 
 | ||||
| 		$result = $this->Html->image(array( | ||||
| 			'controller' => 'images', | ||||
| 			'action' => 'display', | ||||
| 			'test', | ||||
| 			'?' => array('one' => 'two', 'three' => 'four') | ||||
| 		)); | ||||
| 		$this->assertTags($result, array('img' => array('src' => '/images/display/test?one=two&three=four', 'alt' => ''))); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that image works with pathPrefix. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testImagePathPrefix() { | ||||
| 		$result = $this->Html->image('test.gif', array('pathPrefix' => '/my/custom/path/')); | ||||
| 		$this->assertTags($result, array('img' => array('src' => '/my/custom/path/test.gif', 'alt' => ''))); | ||||
| 
 | ||||
| 		$result = $this->Html->image('test.gif', array('pathPrefix' => 'http://cakephp.org/assets/img/')); | ||||
| 		$this->assertTags($result, array('img' => array('src' => 'http://cakephp.org/assets/img/test.gif', 'alt' => ''))); | ||||
| 
 | ||||
| 		$result = $this->Html->image('test.gif', array('pathPrefix' => '//cakephp.org/assets/img/')); | ||||
| 		$this->assertTags($result, array('img' => array('src' => '//cakephp.org/assets/img/test.gif', 'alt' => ''))); | ||||
| 
 | ||||
| 		$previousConfig = Configure::read('App.imageBaseUrl'); | ||||
| 		Configure::write('App.imageBaseUrl', '//cdn.cakephp.org/img/'); | ||||
| 		$result = $this->Html->image('test.gif'); | ||||
| 		$this->assertTags($result, array('img' => array('src' => '//cdn.cakephp.org/img/test.gif', 'alt' => ''))); | ||||
| 		Configure::write('App.imageBaseUrl', $previousConfig); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -425,7 +519,7 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		App::uses('File', 'Utility'); | ||||
| 
 | ||||
| 		$testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif'; | ||||
| 		$File = new File($testfile, true); | ||||
| 		new File($testfile, true); | ||||
| 
 | ||||
| 		App::build(array( | ||||
| 			'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) | ||||
|  | @ -525,7 +619,7 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		CakePlugin::load('TestPlugin'); | ||||
| 		$result = $this->Html->css('TestPlugin.style', null, array('plugin' => false)); | ||||
| 		$result = $this->Html->css('TestPlugin.style', array('plugin' => false)); | ||||
| 		$expected['link']['href'] = 'preg:/.*css\/TestPlugin\.style\.css/'; | ||||
| 		$this->assertTags($result, $expected); | ||||
| 		CakePlugin::unload('TestPlugin'); | ||||
|  | @ -546,6 +640,21 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/'; | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->css('cake.generic', array('pathPrefix' => '/my/custom/path/')); | ||||
| 		$expected['link']['href'] = '/my/custom/path/cake.generic.css'; | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->css('cake.generic', array('pathPrefix' => 'http://cakephp.org/assets/css/')); | ||||
| 		$expected['link']['href'] = 'http://cakephp.org/assets/css/cake.generic.css'; | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$previousConfig = Configure::read('App.cssBaseUrl'); | ||||
| 		Configure::write('App.cssBaseUrl', '//cdn.cakephp.org/css/'); | ||||
| 		$result = $this->Html->css('cake.generic'); | ||||
| 		$expected['link']['href'] = '//cdn.cakephp.org/css/cake.generic.css'; | ||||
| 		$this->assertTags($result, $expected); | ||||
| 		Configure::write('App.cssBaseUrl', $previousConfig); | ||||
| 
 | ||||
| 		Configure::write('Asset.filter.css', 'css.php'); | ||||
| 		$result = $this->Html->css('cake.generic'); | ||||
| 		$expected['link']['href'] = 'preg:/.*ccss\/cake\.generic\.css/'; | ||||
|  | @ -572,6 +681,74 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 			->method('append') | ||||
| 			->with('css', $this->matchesRegularExpression('/more_css_in_head.css/')); | ||||
| 
 | ||||
| 		$result = $this->Html->css('css_in_head', array('inline' => false)); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
| 		$result = $this->Html->css('more_css_in_head', array('inline' => false)); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
| 		$result = $this->Html->css('screen', array('rel' => 'import')); | ||||
| 		$expected = array( | ||||
| 			'style' => array('type' => 'text/css'), | ||||
| 			'preg:/@import url\(.*css\/screen\.css\);/', | ||||
| 			'/style' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test css() with once option. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCssLinkOnce() { | ||||
| 		Configure::write('Asset.filter.css', false); | ||||
| 
 | ||||
| 		$result = $this->Html->css('screen', array('once' => true)); | ||||
| 		$expected = array( | ||||
| 			'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\/screen\.css/') | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->css('screen', array('once' => true)); | ||||
| 		$this->assertEquals('', $result); | ||||
| 
 | ||||
| 		// Default is once=false
 | ||||
| 		$result = $this->Html->css('screen'); | ||||
| 		$expected = array( | ||||
| 			'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\/screen\.css/') | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test css link BC usage | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCssLinkBC() { | ||||
| 		Configure::write('Asset.filter.css', false); | ||||
| 
 | ||||
| 		CakePlugin::load('TestPlugin'); | ||||
| 		$result = $this->Html->css('TestPlugin.style', null, array('plugin' => false)); | ||||
| 		$expected = array( | ||||
| 			'link' => array( | ||||
| 				'rel' => 'stylesheet', | ||||
| 				'type' => 'text/css', | ||||
| 				'href' => 'preg:/.*css\/TestPlugin\.style\.css/' | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 		CakePlugin::unload('TestPlugin'); | ||||
| 
 | ||||
| 		$result = $this->Html->css('screen', 'import'); | ||||
| 		$expected = array( | ||||
| 			'style' => array('type' => 'text/css'), | ||||
| 			'preg:/@import url\(.*css\/screen\.css\);/', | ||||
| 			'/style' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->css('css_in_head', null, array('inline' => false)); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
|  | @ -579,6 +756,22 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$this->assertNull($result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCssWithFullBase method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCssWithFullBase() { | ||||
| 		Configure::write('Asset.filter.css', false); | ||||
| 		$here = $this->Html->url('/', true); | ||||
| 
 | ||||
| 		$result = $this->Html->css('screen', null, array('fullBase' => true)); | ||||
| 		$expected = array( | ||||
| 			'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $here . 'css/screen.css') | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testPluginCssLink method | ||||
|  * | ||||
|  | @ -706,13 +899,29 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		CakePlugin::unload('TestPlugin'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Resource names must be treated differently for css() and script() | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testBufferedCssAndScriptWithIdenticalResourceName() { | ||||
| 		$this->View->expects($this->at(0)) | ||||
| 			->method('append') | ||||
| 			->with('css', $this->stringContains('test.min.css')); | ||||
| 		$this->View->expects($this->at(1)) | ||||
| 			->method('append') | ||||
| 			->with('script', $this->stringContains('test.min.js')); | ||||
| 		$this->Html->css('test.min', array('inline' => false)); | ||||
| 		$this->Html->script('test.min', array('inline' => false)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test timestamp enforcement for script tags. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testScriptTimestamping() { | ||||
| 		$this->skipIf(!is_writable(JS), 'webroot/js is not Writable, timestamp testing has been skipped.'); | ||||
| 		$this->skipIf(!is_writable(WWW_ROOT . 'js'), 'webroot/js is not Writable, timestamp testing has been skipped.'); | ||||
| 
 | ||||
| 		Configure::write('debug', 2); | ||||
| 		Configure::write('Asset.timestamp', true); | ||||
|  | @ -739,7 +948,7 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 	public function testPluginScriptTimestamping() { | ||||
| 		CakePlugin::load('TestPlugin'); | ||||
| 
 | ||||
| 		$pluginPath = App::pluginPath('TestPlugin'); | ||||
| 		$pluginPath = CakePlugin::path('TestPlugin'); | ||||
| 		$pluginJsPath = $pluginPath . 'webroot/js'; | ||||
| 		$this->skipIf(!is_writable($pluginJsPath), $pluginJsPath . ' is not Writable, timestamp testing has been skipped.'); | ||||
| 
 | ||||
|  | @ -820,6 +1029,27 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->script('foo2', array('pathPrefix' => '/my/custom/path/')); | ||||
| 		$expected = array( | ||||
| 			'script' => array('type' => 'text/javascript', 'src' => '/my/custom/path/foo2.js') | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->script('foo3', array('pathPrefix' => 'http://cakephp.org/assets/js/')); | ||||
| 		$expected = array( | ||||
| 			'script' => array('type' => 'text/javascript', 'src' => 'http://cakephp.org/assets/js/foo3.js') | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$previousConfig = Configure::read('App.jsBaseUrl'); | ||||
| 		Configure::write('App.jsBaseUrl', '//cdn.cakephp.org/js/'); | ||||
| 		$result = $this->Html->script('foo4'); | ||||
| 		$expected = array( | ||||
| 			'script' => array('type' => 'text/javascript', 'src' => '//cdn.cakephp.org/js/foo4.js') | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 		Configure::write('App.jsBaseUrl', $previousConfig); | ||||
| 
 | ||||
| 		$result = $this->Html->script('foo'); | ||||
| 		$this->assertNull($result, 'Script returned upon duplicate inclusion %s'); | ||||
| 
 | ||||
|  | @ -951,6 +1181,30 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testScriptWithFullBase method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testScriptWithFullBase() { | ||||
| 		$here = $this->Html->url('/', true); | ||||
| 
 | ||||
| 		$result = $this->Html->script('foo', array('fullBase' => true)); | ||||
| 		$expected = array( | ||||
| 			'script' => array('type' => 'text/javascript', 'src' => $here . 'js/foo.js') | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->script(array('foobar', 'bar'), array('fullBase' => true)); | ||||
| 		$expected = array( | ||||
| 			array('script' => array('type' => 'text/javascript', 'src' => $here . 'js/foobar.js')), | ||||
| 			'/script', | ||||
| 			array('script' => array('type' => 'text/javascript', 'src' => $here . 'js/bar.js')), | ||||
| 			'/script', | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test a script file in the webroot/theme dir. | ||||
|  * | ||||
|  | @ -963,7 +1217,7 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		App::uses('File', 'Utility'); | ||||
| 
 | ||||
| 		$testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js'; | ||||
| 		$File = new File($testfile, true); | ||||
| 		new File($testfile, true); | ||||
| 
 | ||||
| 		App::build(array( | ||||
| 			'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) | ||||
|  | @ -1002,6 +1256,16 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->scriptBlock('window.foo = 2;', array('type' => 'text/x-handlebars-template')); | ||||
| 		$expected = array( | ||||
| 			'script' => array('type' => 'text/x-handlebars-template'), | ||||
| 			$this->cDataStart, | ||||
| 			'window.foo = 2;', | ||||
| 			$this->cDataEnd, | ||||
| 			'/script', | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false)); | ||||
| 		$expected = array( | ||||
| 			'script' => array('type' => 'text/javascript'), | ||||
|  | @ -1075,6 +1339,20 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->scriptStart(array('safe' => true, 'type' => 'text/x-handlebars-template')); | ||||
| 		$this->assertNull($result); | ||||
| 		echo 'this is some template'; | ||||
| 
 | ||||
| 		$result = $this->Html->scriptEnd(); | ||||
| 		$expected = array( | ||||
| 			'script' => array('type' => 'text/x-handlebars-template'), | ||||
| 			$this->cDataStart, | ||||
| 			'this is some template', | ||||
| 			$this->cDataEnd, | ||||
| 			'/script' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$this->View->expects($this->once()) | ||||
| 			->method('append'); | ||||
| 		$result = $this->Html->scriptStart(array('safe' => false, 'inline' => false)); | ||||
|  | @ -1192,6 +1470,8 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Test the array form of $startText | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGetCrumbFirstLink() { | ||||
| 		$result = $this->Html->getCrumbList(null, 'Home'); | ||||
|  | @ -1473,22 +1753,8 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->meta('icon', 'favicon.ico'); | ||||
| 		$expected = array( | ||||
| 			'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'), | ||||
| 			array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon')) | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 		$result = $this->Html->meta('icon'); | ||||
| 		$expected = array( | ||||
| 			'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'), | ||||
| 			array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon')) | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->meta('keywords', 'these, are, some, meta, keywords'); | ||||
| 		$this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords'))); | ||||
| 		$this->assertRegExp('/\s+\/>$/', $result); | ||||
| 
 | ||||
| 		$result = $this->Html->meta('description', 'this is the meta description'); | ||||
| 		$this->assertTags($result, array('meta' => array('name' => 'description', 'content' => 'this is the meta description'))); | ||||
|  | @ -1497,8 +1763,57 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL'))); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test generating favicon's with meta() | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testMetaIcon() { | ||||
| 		$result = $this->Html->meta('icon', 'favicon.ico'); | ||||
| 		$expected = array( | ||||
| 			'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'), | ||||
| 			array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon')) | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->meta('icon'); | ||||
| 		$expected = array( | ||||
| 			'link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'icon'), | ||||
| 			array('link' => array('href' => 'preg:/.*favicon\.ico/', 'type' => 'image/x-icon', 'rel' => 'shortcut icon')) | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$result = $this->Html->meta('icon', '/favicon.png?one=two&three=four'); | ||||
| 		$url = '/favicon.png?one=two&three=four'; | ||||
| 		$expected = array( | ||||
| 			'link' => array( | ||||
| 				'href' => $url, | ||||
| 				'type' => 'image/x-icon', | ||||
| 				'rel' => 'icon' | ||||
| 			), | ||||
| 			array( | ||||
| 				'link' => array( | ||||
| 					'href' => $url, | ||||
| 					'type' => 'image/x-icon', | ||||
| 					'rel' => 'shortcut icon' | ||||
| 				) | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$this->Html->request->webroot = '/testing/'; | ||||
| 		$result = $this->Html->meta('icon'); | ||||
| 		$expected = array( | ||||
| 			'link' => array('href' => '/testing/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'icon'), | ||||
| 			array('link' => array('href' => '/testing/favicon.ico', 'type' => 'image/x-icon', 'rel' => 'shortcut icon')) | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the inline and block options for meta() | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testMetaWithBlocks() { | ||||
| 		$this->View->expects($this->at(0)) | ||||
|  | @ -1610,6 +1925,21 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$result = $this->Html->tableCells($tr, array('class' => 'odd'), array('class' => 'even'), false, false); | ||||
| 		$expected = "<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"even\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>\n<tr class=\"odd\"><td>td content 1</td> <td>td content 2</td> <td>td content 3</td></tr>"; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$tr = array( | ||||
| 			'td content 1', | ||||
| 			'td content 2', | ||||
| 			array('td content 3', array('class' => 'foo')) | ||||
| 		); | ||||
| 		$result = $this->Html->tableCells($tr, null, null, true); | ||||
| 		$expected = array( | ||||
| 			'<tr', | ||||
| 			array('td' => array('class' => 'column-1')), 'td content 1', '/td', | ||||
| 			array('td' => array('class' => 'column-2')), 'td content 2', '/td', | ||||
| 			array('td' => array('class' => 'foo column-3')), 'td content 3', '/td', | ||||
| 			'/tr' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -1624,11 +1954,17 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$result = $this->Html->tag('div', 'text'); | ||||
| 		$this->assertTags($result, '<div', 'text', '/div'); | ||||
| 
 | ||||
| 		$result = $this->Html->tag('div', '<text>', 'class-name'); | ||||
| 		$this->assertTags($result, array('div' => array('class' => 'class-name'), 'preg:/<text>/', '/div')); | ||||
| 
 | ||||
| 		$result = $this->Html->tag('div', '<text>', array('class' => 'class-name', 'escape' => true)); | ||||
| 		$this->assertTags($result, array('div' => array('class' => 'class-name'), '<text>', '/div')); | ||||
| 
 | ||||
| 		$result = $this->Html->tag(false, '<em>stuff</em>'); | ||||
| 		$this->assertEquals('<em>stuff</em>', $result); | ||||
| 
 | ||||
| 		$result = $this->Html->tag(null, '<em>stuff</em>'); | ||||
| 		$this->assertEquals('<em>stuff</em>', $result); | ||||
| 
 | ||||
| 		$result = $this->Html->tag('', '<em>stuff</em>'); | ||||
| 		$this->assertEquals('<em>stuff</em>', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -1714,7 +2050,7 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 			array('pathPrefix' => 'videos/', 'poster' => 'poster.jpg', 'text' => 'Your browser does not support the HTML5 Video element.') | ||||
| 		); | ||||
| 		$expected = array( | ||||
| 			'video' => array('poster' => IMAGES_URL . 'poster.jpg'), | ||||
| 			'video' => array('poster' => Configure::read('App.imageBaseUrl') . 'poster.jpg'), | ||||
| 				array('source' => array('src' => 'videos/video.webm', 'type' => 'video/webm')), | ||||
| 				array('source' => array('src' => 'videos/video.ogv', 'type' => 'video/ogg; codecs='theora, vorbis'')), | ||||
| 				'Your browser does not support the HTML5 Video element.', | ||||
|  | @ -1752,7 +2088,6 @@ class HtmlHelperTest extends CakeTestCase { | |||
| /** | ||||
|  * testCrumbList method | ||||
|  * | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCrumbList() { | ||||
|  | @ -1784,6 +2119,8 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Test getCrumbList startText | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCrumbListFirstLink() { | ||||
| 		$this->Html->addCrumb('First', '#first'); | ||||
|  | @ -1826,6 +2163,73 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test getCrumbList() in Twitter Bootstrap style. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCrumbListBootstrapStyle() { | ||||
| 		$this->Html->addCrumb('Home', '/', array('class' => 'home')); | ||||
| 		$this->Html->addCrumb('Library', '/lib'); | ||||
| 		$this->Html->addCrumb('Data'); | ||||
| 		$result = $this->Html->getCrumbList(array( | ||||
| 			'class' => 'breadcrumb', | ||||
| 			'separator' => '<span class="divider">-</span>', | ||||
| 			'firstClass' => false, | ||||
| 			'lastClass' => 'active' | ||||
| 		)); | ||||
| 		$this->assertTags( | ||||
| 			$result, | ||||
| 			array( | ||||
| 				array('ul' => array('class' => 'breadcrumb')), | ||||
| 				'<li', | ||||
| 				array('a' => array('class' => 'home', 'href' => '/')), 'Home', '/a', | ||||
| 				array('span' => array('class' => 'divider')), '-', '/span', | ||||
| 				'/li', | ||||
| 				'<li', | ||||
| 				array('a' => array('href' => '/lib')), 'Library', '/a', | ||||
| 				array('span' => array('class' => 'divider')), '-', '/span', | ||||
| 				'/li', | ||||
| 				array('li' => array('class' => 'active')), 'Data', '/li', | ||||
| 				'/ul' | ||||
| 			) | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test GetCrumbList using style of Zurb Foundation. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCrumbListZurbStyle() { | ||||
| 		$this->Html->addCrumb('Home', '#'); | ||||
| 		$this->Html->addCrumb('Features', '#'); | ||||
| 		$this->Html->addCrumb('Gene Splicing', '#'); | ||||
| 		$this->Html->addCrumb('Home', '#'); | ||||
| 		$result = $this->Html->getCrumbList( | ||||
| 			array('class' => 'breadcrumbs', 'firstClass' => false, 'lastClass' => 'current') | ||||
| 		); | ||||
| 		$this->assertTags( | ||||
| 			$result, | ||||
| 			array( | ||||
| 				array('ul' => array('class' => 'breadcrumbs')), | ||||
| 				'<li', | ||||
| 				array('a' => array('href' => '#')), 'Home', '/a', | ||||
| 				'/li', | ||||
| 				'<li', | ||||
| 				array('a' => array('href' => '#')), 'Features', '/a', | ||||
| 				'/li', | ||||
| 				'<li', | ||||
| 				array('a' => array('href' => '#')), 'Gene Splicing', '/a', | ||||
| 				'/li', | ||||
| 				array('li' => array('class' => 'current')), | ||||
| 				array('a' => array('href' => '#')), 'Home', '/a', | ||||
| 				'/li', | ||||
| 				'/ul' | ||||
| 			), true | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testLoadConfig method | ||||
|  * | ||||
|  | @ -1839,7 +2243,8 @@ class HtmlHelperTest extends CakeTestCase { | |||
| 		$expected = array( | ||||
| 			'tags' => array( | ||||
| 				'form' => 'start form', | ||||
| 				'formend' => 'finish form' | ||||
| 				'formend' => 'finish form', | ||||
| 				'hiddenblock' => '<div class="hidden">%s</div>' | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
|  | @ -1863,7 +2268,7 @@ class HtmlHelperTest extends CakeTestCase { | |||
|  * @expectedException ConfigureException | ||||
|  */ | ||||
| 	public function testLoadConfigWrongFile() { | ||||
| 		$result = $this->Html->loadConfig('wrong_file'); | ||||
| 		$this->Html->loadConfig('wrong_file'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -1874,7 +2279,7 @@ class HtmlHelperTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testLoadConfigWrongReader() { | ||||
| 		$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS; | ||||
| 		$result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); | ||||
| 		$this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko