mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 00:03: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 @@ | |||
| /** | ||||
|  * CacheHelperTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. (http://cakefoundation.org) | ||||
|  * @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'); | ||||
|  | @ -151,7 +150,7 @@ class CacheHelperTest extends CakeTestCase { | |||
| 		$this->Controller->action = 'view'; | ||||
| 
 | ||||
| 		$View = new View($this->Controller); | ||||
| 		$result = $View->render('index'); | ||||
| 		$View->render('index'); | ||||
| 
 | ||||
| 		$filename = CACHE . 'views' . DS . 'posts_view_風街ろまん.php'; | ||||
| 		$this->assertTrue(file_exists($filename)); | ||||
|  | @ -338,7 +337,7 @@ class CacheHelperTest extends CakeTestCase { | |||
| 		$this->Controller->cache_parsing(); | ||||
| 
 | ||||
| 		$View = new View($this->Controller); | ||||
| 		$result = $View->render('index'); | ||||
| 		$View->render('index'); | ||||
| 
 | ||||
| 		$filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php'; | ||||
| 		$this->assertTrue(file_exists($filename)); | ||||
|  | @ -514,10 +513,10 @@ class CacheHelperTest extends CakeTestCase { | |||
|  * | ||||
|  * This test verifies view cache is created correctly when the app name is contained in part of the controller name. | ||||
|  * (webapp Name) base name is 'cache' controller is 'cacheTest' action is 'cache_name' | ||||
|  * apps url would look something like http://localhost/cache/cacheTest/cache_name | ||||
|  * apps URL would look something like http://localhost/cache/cacheTest/cache_name | ||||
|  * | ||||
|  * @return void | ||||
|  **/ | ||||
|  */ | ||||
| 	public function testCacheBaseNameControllerName() { | ||||
| 		$this->Controller->cache_parsing(); | ||||
| 		$this->Controller->cacheAction = array( | ||||
|  |  | |||
							
								
								
									
										172
									
								
								lib/Cake/Test/Case/View/Helper/FlashHelperTest.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								lib/Cake/Test/Case/View/Helper/FlashHelperTest.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,172 @@ | |||
| <?php | ||||
| /** | ||||
|  * FlashHelperTest file | ||||
|  * | ||||
|  * Series of tests for flash helper. | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * 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 (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 2.7.0-dev | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('FlashHelper', 'View/Helper'); | ||||
| App::uses('View', 'View'); | ||||
| App::uses('CakePlugin', 'Core'); | ||||
| 
 | ||||
| /** | ||||
|  * FlashHelperTest class | ||||
|  * | ||||
|  * @package		Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class FlashHelperTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  * setupBeforeClass method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public static function setupBeforeClass() { | ||||
| 		App::build(array( | ||||
| 			'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) | ||||
| 		)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * setUp method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		$controller = null; | ||||
| 		$this->View = new View($controller); | ||||
| 		$this->Flash = new FlashHelper($this->View); | ||||
| 
 | ||||
| 		if (!CakeSession::started()) { | ||||
| 			CakeSession::start(); | ||||
| 		} | ||||
| 		CakeSession::write(array( | ||||
| 			'Message' => array( | ||||
| 				'flash' => array( | ||||
| 					'key' => 'flash', | ||||
| 					'message' => 'This is a calling', | ||||
| 					'element' => 'Flash/default', | ||||
| 					'params' => array() | ||||
| 				), | ||||
| 				'notification' => array( | ||||
| 					'key' => 'notification', | ||||
| 					'message' => 'Broadcast message testing', | ||||
| 					'element' => 'flash_helper', | ||||
| 					'params' => array( | ||||
| 						'title' => 'Notice!', | ||||
| 						'name' => 'Alert!' | ||||
| 					) | ||||
| 				), | ||||
| 				'classy' => array( | ||||
| 					'key' => 'classy', | ||||
| 					'message' => 'Recorded', | ||||
| 					'element' => 'flash_classy', | ||||
| 					'params' => array() | ||||
| 				), | ||||
| 				'default' => array( | ||||
| 					'key' => 'default', | ||||
| 					'message' => 'Default', | ||||
| 					'element' => 'default', | ||||
| 					'params' => array() | ||||
| 				) | ||||
| 			) | ||||
| 		)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * tearDown method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
| 		unset($this->View, $this->Flash); | ||||
| 		CakeSession::destroy(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testFlash method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFlash() { | ||||
| 		$result = $this->Flash->render(); | ||||
| 		$expected = '<div class="message">This is a calling</div>'; | ||||
| 		$this->assertContains($expected, $result); | ||||
| 
 | ||||
| 		$expected = '<div id="classy-message">Recorded</div>'; | ||||
| 		$result = $this->Flash->render('classy'); | ||||
| 		$this->assertContains($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->Flash->render('notification'); | ||||
| 		$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>Broadcast message testing</p>\n</div>"; | ||||
| 		$this->assertContains($expected, $result); | ||||
| 
 | ||||
| 		$this->assertNull($this->Flash->render('non-existent')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testFlashThrowsException | ||||
|  * | ||||
|  * @expectedException UnexpectedValueException | ||||
|  */ | ||||
| 	public function testFlashThrowsException() { | ||||
| 		CakeSession::write('Message.foo', 'bar'); | ||||
| 		$this->Flash->render('foo'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test setting the element from the attrs. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFlashElementInAttrs() { | ||||
| 		$result = $this->Flash->render('notification', array( | ||||
| 			'element' => 'flash_helper', | ||||
| 			'params' => array('title' => 'Alert!', 'name' => 'Notice!') | ||||
| 		)); | ||||
| 
 | ||||
| 		$expected = "<div id=\"notificationLayout\">\n\t<h1>Notice!</h1>\n\t<h3>Alert!</h3>\n\t<p>Broadcast message testing</p>\n</div>"; | ||||
| 
 | ||||
| 		$this->assertContains($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test using elements in plugins. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFlashWithPluginElement() { | ||||
| 		App::build(array( | ||||
| 			'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) | ||||
| 		)); | ||||
| 		CakePlugin::load('TestPlugin'); | ||||
| 
 | ||||
| 		$result = $this->Flash->render('flash', array('element' => 'TestPlugin.plugin_element')); | ||||
| 		$expected = 'this is the plugin element'; | ||||
| 		$this->assertContains($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that the default element fallbacks to the Flash/default element. | ||||
|  */ | ||||
| 	public function testFlashFallback() { | ||||
| 		$result = $this->Flash->render('default'); | ||||
| 		$expected = '<div class="message">Default</div>'; | ||||
| 		$this->assertContains($expected, $result); | ||||
| 	} | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -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); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  |  | |||
|  | @ -2,18 +2,17 @@ | |||
| /** | ||||
|  * JqueryEngineTestCase | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. | ||||
|  * @link            http://cakephp.org CakePHP Project | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  * @license         MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('HtmlHelper', 'View/Helper'); | ||||
|  | @ -21,6 +20,11 @@ App::uses('JsHelper', 'View/Helper'); | |||
| App::uses('JqueryEngineHelper', 'View/Helper'); | ||||
| App::uses('View', 'View'); | ||||
| 
 | ||||
| /** | ||||
|  * JqueryEngineHelperTest | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class JqueryEngineHelperTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  | @ -213,6 +217,17 @@ class JqueryEngineHelperTest extends CakeTestCase { | |||
| 		)); | ||||
| 		$expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\\/people\\/edit\\/1"});'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->Jquery->request('/people/edit/1', array( | ||||
| 			'success' => 'doFoo', | ||||
| 			'xhr' => 'return jQuery.ajaxSettings.xhr();', | ||||
| 			'async' => true, | ||||
| 			'method' => 'post', | ||||
| 			'dataExpression' => true, | ||||
| 			'data' => '$("#someId").serialize()', | ||||
| 		)); | ||||
| 		$expected = '$.ajax({async:true, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\/people\/edit\/1", xhr:function () {return jQuery.ajaxSettings.xhr();}});'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  |  | |||
|  | @ -4,20 +4,20 @@ | |||
|  * | ||||
|  * TestCase for the JsHelper | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. (http://cakefoundation.org) | ||||
|  * @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.3 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('HtmlHelper', 'View/Helper'); | ||||
| App::uses('JsHelper', 'View/Helper'); | ||||
| App::uses('JsBaseEngineHelper', 'View/Helper'); | ||||
|  | @ -25,6 +25,11 @@ App::uses('FormHelper', 'View/Helper'); | |||
| App::uses('View', 'View'); | ||||
| App::uses('ClassRegistry', 'Utility'); | ||||
| 
 | ||||
| /** | ||||
|  * JsEncodingObject | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class JsEncodingObject { | ||||
| 
 | ||||
| 	protected $_title = 'Old thing'; | ||||
|  | @ -35,6 +40,11 @@ class JsEncodingObject { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * OptionEngineHelper | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class OptionEngineHelper extends JsBaseEngineHelper { | ||||
| 
 | ||||
| 	protected $_optionMap = array( | ||||
|  | @ -48,6 +58,7 @@ class OptionEngineHelper extends JsBaseEngineHelper { | |||
| /** | ||||
|  * test method for testing option mapping | ||||
|  * | ||||
|  * @param array $options | ||||
|  * @return array | ||||
|  */ | ||||
| 	public function testMap($options = array()) { | ||||
|  | @ -57,6 +68,8 @@ class OptionEngineHelper extends JsBaseEngineHelper { | |||
| /** | ||||
|  * test method for option parsing | ||||
|  * | ||||
|  * @param $options | ||||
|  * @param array $safe | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testParseOptions($options, $safe = array()) { | ||||
|  | @ -161,13 +174,8 @@ class JsHelperTest extends CakeTestCase { | |||
| 	protected function _useMock() { | ||||
| 		$request = new CakeRequest(null, false); | ||||
| 
 | ||||
| 		if (!class_exists('TestJsEngineHelper', false)) { | ||||
| 			$this->getMock('JsBaseEngineHelper', array(), array($this->View), 'TestJsEngineHelper'); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->Js = new JsHelper($this->View, array('TestJs')); | ||||
| 		$this->Js->TestJsEngine = new TestJsEngineHelper($this->View); | ||||
| 		$this->mockObjects[] = $this->Js->TestJsEngine; | ||||
| 		$this->Js->TestJsEngine = $this->getMock('JsBaseEngineHelper', array(), array($this->View)); | ||||
| 		$this->Js->request = $request; | ||||
| 		$this->Js->Html = new HtmlHelper($this->View); | ||||
| 		$this->Js->Html->request = $request; | ||||
|  | @ -319,7 +327,7 @@ class JsHelperTest extends CakeTestCase { | |||
| 			->method('append') | ||||
| 			->with('script', $this->matchesRegularExpression('#<script type="text\/javascript">window.app \= \{"foo"\:1\}\;<\/script>#')); | ||||
| 
 | ||||
| 		$result = $this->Js->writeBuffer(array('onDomReady' => false, 'inline' => false, 'safe' => false)); | ||||
| 		$this->Js->writeBuffer(array('onDomReady' => false, 'inline' => false, 'safe' => false)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -338,7 +346,7 @@ class JsHelperTest extends CakeTestCase { | |||
| 
 | ||||
| 		$this->Js->buffer('alert("test");'); | ||||
| 		$this->Js->TestJsEngine->expects($this->never())->method('domReady'); | ||||
| 		$result = $this->Js->writeBuffer(); | ||||
| 		$this->Js->writeBuffer(); | ||||
| 
 | ||||
| 		unset($_SERVER['HTTP_X_REQUESTED_WITH']); | ||||
| 		if ($requestWith !== null) { | ||||
|  | @ -352,11 +360,11 @@ class JsHelperTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testWriteScriptsInFile() { | ||||
| 		$this->skipIf(!is_writable(JS), 'webroot/js is not Writable, script caching test has been skipped.'); | ||||
| 		$this->skipIf(!is_writable(WWW_ROOT . 'js'), 'webroot/js is not Writable, script caching test has been skipped.'); | ||||
| 
 | ||||
| 		Configure::write('Cache.disable', false); | ||||
| 		$this->Js->request->webroot = '/'; | ||||
| 		$this->Js->JsBaseEngine = new TestJsEngineHelper($this->View); | ||||
| 		$this->Js->JsBaseEngine = $this->getMock('JsBaseEngineHelper', array(), array($this->View)); | ||||
| 		$this->Js->buffer('one = 1;'); | ||||
| 		$this->Js->buffer('two = 2;'); | ||||
| 		$result = $this->Js->writeBuffer(array('onDomReady' => false, 'cache' => true)); | ||||
|  | @ -684,7 +692,7 @@ class JsHelperTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test set()'ing variables to the Javascript buffer and controlling the output var name. | ||||
|  * test set()'ing variables to the JavaScript buffer and controlling the output var name. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -858,7 +866,7 @@ class JsBaseEngineTest extends CakeTestCase { | |||
| 
 | ||||
| 		$object = new JsEncodingObject(); | ||||
| 		$object->title = 'New thing'; | ||||
| 		$object->indexes = array(5,6,7,8); | ||||
| 		$object->indexes = array(5, 6, 7, 8); | ||||
| 		$result = $this->JsEngine->object($object); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,18 +2,17 @@ | |||
| /** | ||||
|  * MooEngineTestCase | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. | ||||
|  * @link            http://cakephp.org CakePHP Project | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  * @license         MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('View', 'View'); | ||||
|  | @ -21,6 +20,11 @@ App::uses('HtmlHelper', 'View/Helper'); | |||
| App::uses('JsHelper', 'View/Helper'); | ||||
| App::uses('MootoolsEngineHelper', 'View/Helper'); | ||||
| 
 | ||||
| /** | ||||
|  * MootoolsEngineHelperTest | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class MootoolsEngineHelperTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  | @ -260,7 +264,7 @@ class MootoolsEngineHelperTest extends CakeTestCase { | |||
| 			'start' => 'onStart', | ||||
| 			'drag' => 'onDrag', | ||||
| 			'stop' => 'onStop', | ||||
| 			'snapGrid' => array(10,10), | ||||
| 			'snapGrid' => array(10, 10), | ||||
| 			'wrapCallbacks' => false | ||||
| 		)); | ||||
| 		$expected = '$("drag-me").makeDraggable({onComplete:onStop, onDrag:onDrag, onStart:onStart, snap:[10,10]});'; | ||||
|  |  | |||
|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * NumberHelperTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. (http://cakefoundation.org) | ||||
|  * @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('View', 'View'); | ||||
|  | @ -70,6 +69,8 @@ class NumberHelperTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * test CakeNumber class methods are called correctly | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testNumberHelperProxyMethodCalls() { | ||||
| 		$methods = array( | ||||
|  | @ -87,6 +88,8 @@ class NumberHelperTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * test engine override | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testEngineOverride() { | ||||
| 		App::build(array( | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -2,18 +2,17 @@ | |||
| /** | ||||
|  * PrototypeEngine TestCase | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. | ||||
|  * @link            http://cakephp.org CakePHP Project | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  * @license         MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('View', 'View'); | ||||
|  | @ -21,6 +20,11 @@ App::uses('HtmlHelper', 'View/Helper'); | |||
| App::uses('JsHelper', 'View/Helper'); | ||||
| App::uses('PrototypeEngineHelper', 'View/Helper'); | ||||
| 
 | ||||
| /** | ||||
|  * PrototypeEngineHelperTest | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class PrototypeEngineHelperTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  | @ -283,8 +287,8 @@ class PrototypeEngineHelperTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test drag() method.  Scriptaculous lacks the ability to take an Array of Elements | ||||
|  * in new Drag() when selection is a multiple type.  Iterate over the array. | ||||
|  * test drag() method. Scriptaculous lacks the ability to take an Array of Elements | ||||
|  * in new Drag() when selection is a multiple type. Iterate over the array. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  |  | |||
|  | @ -2,20 +2,20 @@ | |||
| /** | ||||
|  * RssHelperTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. (http://cakefoundation.org) | ||||
|  * @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('View', 'View'); | ||||
| App::uses('RssHelper', 'View/Helper'); | ||||
| App::uses('TimeHelper', 'View/Helper'); | ||||
|  | @ -91,7 +91,7 @@ class RssHelperTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testChannel() { | ||||
| 		$attrib = array('a' => '1', 'b' => '2'); | ||||
| 		$elements = array('title' => 'title'); | ||||
| 		$elements = array('title' => 'Title'); | ||||
| 		$content = 'content'; | ||||
| 
 | ||||
| 		$result = $this->Rss->channel($attrib, $elements, $content); | ||||
|  | @ -101,30 +101,7 @@ class RssHelperTest extends CakeTestCase { | |||
| 				'b' => '2' | ||||
| 			), | ||||
| 			'<title', | ||||
| 			'title', | ||||
| 			'/title', | ||||
| 			'<link', | ||||
| 			$this->Rss->url('/', true), | ||||
| 			'/link', | ||||
| 			'<description', | ||||
| 			'content', | ||||
| 			'/channel' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$this->View->pageTitle = 'title'; | ||||
| 		$attrib = array('a' => '1', 'b' => '2'); | ||||
| 		$elements = array(); | ||||
| 		$content = 'content'; | ||||
| 
 | ||||
| 		$result = $this->Rss->channel($attrib, $elements, $content); | ||||
| 		$expected = array( | ||||
| 			'channel' => array( | ||||
| 				'a' => '1', | ||||
| 				'b' => '2' | ||||
| 			), | ||||
| 			'<title', | ||||
| 			'title', | ||||
| 			'Title', | ||||
| 			'/title', | ||||
| 			'<link', | ||||
| 			$this->Rss->url('/', true), | ||||
|  | @ -608,7 +585,7 @@ class RssHelperTest extends CakeTestCase { | |||
| 
 | ||||
| 		$this->assertTrue($File->write('123'), 'Could not write to ' . $tmpFile); | ||||
| 
 | ||||
| 		if (50300 <= PHP_VERSION_ID) { | ||||
| 		if (PHP_VERSION_ID >= 50300) { | ||||
| 			clearstatcache(true, $tmpFile); | ||||
| 		} else { | ||||
| 			clearstatcache(); | ||||
|  | @ -642,13 +619,12 @@ class RssHelperTest extends CakeTestCase { | |||
| 			) | ||||
| 		); | ||||
| 		$result = $this->Rss->item(null, $item); | ||||
| 		if (!function_exists('finfo_open') && | ||||
| 			(function_exists('mime_content_type') && false === mime_content_type($tmpFile)) | ||||
| 		) { | ||||
| 			$type = false; | ||||
| 		if (!function_exists('mime_content_type')) { | ||||
| 			$type = null; | ||||
| 		} else { | ||||
| 			$type = 'text/plain'; | ||||
| 			$type = mime_content_type($tmpFile); | ||||
| 		} | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'<item', | ||||
| 			'<title', | ||||
|  | @ -679,6 +655,9 @@ class RssHelperTest extends CakeTestCase { | |||
| 			'/category', | ||||
| 			'/item' | ||||
| 		); | ||||
| 		if ($type === null) { | ||||
| 			unset($expected['enclosure']['type']); | ||||
| 		} | ||||
| 		$this->assertTags($result, $expected); | ||||
| 
 | ||||
| 		$File->delete(); | ||||
|  | @ -741,36 +720,36 @@ class RssHelperTest extends CakeTestCase { | |||
| 
 | ||||
| 	public function testElementNamespaceWithPrefix() { | ||||
| 		$item = array( | ||||
| 				'title'   => 'Title', | ||||
| 				'dc:creator' => 'Alex', | ||||
| 				'xy:description' => 'descriptive words' | ||||
| 			); | ||||
| 			'title' => 'Title', | ||||
| 			'dc:creator' => 'Alex', | ||||
| 			'dc:description' => 'descriptive words' | ||||
| 		); | ||||
| 		$attributes = array( | ||||
| 				'namespace' => array( | ||||
| 						'prefix' => 'dc', | ||||
| 						'url' => 'http://link.com' | ||||
| 				) | ||||
| 			'namespace' => array( | ||||
| 				'prefix' => 'dc', | ||||
| 				'url' => 'http://link.com' | ||||
| 			) | ||||
| 		); | ||||
| 		$result = $this->Rss->item($attributes, $item); | ||||
| 		$expected = array( | ||||
| 			'item' => array( | ||||
| 					'xmlns:dc' => 'http://link.com' | ||||
| 				'xmlns:dc' => 'http://link.com' | ||||
| 			), | ||||
| 			'title' => array( | ||||
| 					'xmlns:dc' => 'http://link.com' | ||||
| 				'xmlns:dc' => 'http://link.com' | ||||
| 			), | ||||
| 			'Title', | ||||
| 			'/title', | ||||
| 			'dc:creator' => array( | ||||
| 					'xmlns:dc' => 'http://link.com' | ||||
| 				'xmlns:dc' => 'http://link.com' | ||||
| 			), | ||||
| 			'Alex', | ||||
| 			'/dc:creator', | ||||
| 			'description' => array( | ||||
| 					'xmlns:dc' => 'http://link.com' | ||||
| 			'dc:description' => array( | ||||
| 				'xmlns:dc' => 'http://link.com' | ||||
| 			), | ||||
| 			'descriptive words', | ||||
| 			'/description', | ||||
| 			'/dc:description', | ||||
| 			'/item' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected, true); | ||||
|  |  | |||
|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * SessionHelperTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. (http://cakefoundation.org) | ||||
|  * @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'); | ||||
|  |  | |||
|  | @ -2,27 +2,31 @@ | |||
| /** | ||||
|  * TextHelperTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. (http://cakefoundation.org) | ||||
|  * @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('View', 'View'); | ||||
| App::uses('TextHelper', 'View/Helper'); | ||||
| 
 | ||||
| /** | ||||
|  * TextHelperTestObject | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class TextHelperTestObject extends TextHelper { | ||||
| 
 | ||||
| 	public function attach(StringMock $string) { | ||||
| 	public function attach(CakeTextMock $string) { | ||||
| 		$this->_engine = $string; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -33,9 +37,11 @@ class TextHelperTestObject extends TextHelper { | |||
| } | ||||
| 
 | ||||
| /** | ||||
|  * StringMock class | ||||
|  * CakeTextMock class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class StringMock { | ||||
| class CakeTextMock { | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -68,22 +74,26 @@ class TextHelperTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * test String class methods are called correctly | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testTextHelperProxyMethodCalls() { | ||||
| 		$methods = array( | ||||
| 			'highlight', 'stripLinks', 'truncate', 'excerpt', 'toList', | ||||
| 			'highlight', 'stripLinks', 'truncate', 'tail', 'excerpt', 'toList', | ||||
| 			); | ||||
| 		$String = $this->getMock('StringMock', $methods); | ||||
| 		$Text = new TextHelperTestObject($this->View, array('engine' => 'StringMock')); | ||||
| 		$Text->attach($String); | ||||
| 		$CakeText = $this->getMock('CakeTextMock', $methods); | ||||
| 		$Text = new TextHelperTestObject($this->View, array('engine' => 'CakeTextMock')); | ||||
| 		$Text->attach($CakeText); | ||||
| 		foreach ($methods as $method) { | ||||
| 			$String->expects($this->at(0))->method($method); | ||||
| 			$CakeText->expects($this->at(0))->method($method); | ||||
| 			$Text->{$method}('who', 'what', 'when', 'where', 'how'); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test engine override | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testEngineOverride() { | ||||
| 		App::build(array( | ||||
|  | @ -107,6 +117,10 @@ class TextHelperTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoLink() { | ||||
| 		$text = 'The AWWWARD show happened today'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($text, $result); | ||||
| 
 | ||||
| 		$text = 'This is a test text'; | ||||
| 		$expected = 'This is a test text'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
|  | @ -117,6 +131,10 @@ class TextHelperTest extends CakeTestCase { | |||
| 		$expected = 'Text with a partial <a href="http://www.cakephp.org">www.cakephp.org</a> URL and <a href="mailto:test@cakephp\.org">test@cakephp\.org</a> email address'; | ||||
| 		$this->assertRegExp('#^' . $expected . '$#', $result); | ||||
| 
 | ||||
| 		$text = 'Text with a partial <a href="//www.cakephp.org">link</a> link'; | ||||
| 		$result = $this->Text->autoLink($text, array('escape' => false)); | ||||
| 		$this->assertEquals($text, $result); | ||||
| 
 | ||||
| 		$text = 'This is a test text with URL http://www.cakephp.org'; | ||||
| 		$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
|  | @ -137,6 +155,51 @@ class TextHelperTest extends CakeTestCase { | |||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'This is a test text with URL (http://www.cakephp.org/page/4) in brackets'; | ||||
| 		$expected = 'This is a test text with URL (<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>) in brackets'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'This is a test text with URL [http://www.cakephp.org/page/4] in square brackets'; | ||||
| 		$expected = 'This is a test text with URL [<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>] in square brackets'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'This is a test text with URL [http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3] in square brackets'; | ||||
| 		$expected = 'This is a test text with URL [<a href="http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3">http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3</a>] in square brackets'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'This is a test text with URL ;http://www.cakephp.org/page/4; semi-colon'; | ||||
| 		$expected = 'This is a test text with URL ;<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>; semi-colon'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'This is a test text with URL (http://www.cakephp.org/page/4/other(thing)) brackets'; | ||||
| 		$expected = 'This is a test text with URL (<a href="http://www.cakephp.org/page/4/other(thing)">http://www.cakephp.org/page/4/other(thing)</a>) brackets'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test mixing URLs and Email addresses in one confusing string. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoLinkMixed() { | ||||
| 		$text = 'Text with a url/email http://example.com/store?email=mark@example.com and email.'; | ||||
| 		$expected = 'Text with a url/email <a href="http://example.com/store?email=mark@example.com">' . | ||||
| 			'http://example.com/store?email=mark@example.com</a> and email.'; | ||||
| 		$result = $this->Text->autoLink($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test autoLink() and options. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoLinkOptions() { | ||||
| 		$text = 'This is a test text with URL http://www.cakephp.org'; | ||||
| 		$expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>'; | ||||
| 		$result = $this->Text->autoLink($text, array('class' => 'link')); | ||||
|  | @ -163,10 +226,23 @@ class TextHelperTest extends CakeTestCase { | |||
| 		$expected = 'This is a <b>test</b> text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>'; | ||||
| 		$result = $this->Text->autoLink($text, array('escape' => false)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'test <ul> | ||||
| 		<li>lorem: http://example.org?some</li> | ||||
| 		<li>ipsum: http://othersite.com/abc</li> | ||||
| 		</ul> test'; | ||||
| 		$expected = 'test <ul> | ||||
| 		<li>lorem: <a href="http://example.org?some">http://example.org?some</a></li> | ||||
| 		<li>ipsum: <a href="http://othersite.com/abc">http://othersite.com/abc</a></li> | ||||
| 		</ul> test'; | ||||
| 		$result = $this->Text->autoLink($text, array('escape' => false)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Data provider for autoLinking | ||||
|  * | ||||
|  * @return array | ||||
|  */ | ||||
| 	public static function autoLinkProvider() { | ||||
| 		return array( | ||||
|  | @ -222,6 +298,18 @@ class TextHelperTest extends CakeTestCase { | |||
| 				'Text with a url http://www.not--work.com and more', | ||||
| 				'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more', | ||||
| 			), | ||||
| 			array( | ||||
| 				'Text with a url http://www.sub_domain.domain.pl and more', | ||||
| 				'Text with a url <a href="http://www.sub_domain.domain.pl">http://www.sub_domain.domain.pl</a> and more', | ||||
| 			), | ||||
| 			array( | ||||
| 				'Text with a partial www.küchenschöhn-not-working.de URL', | ||||
| 				'Text with a partial <a href="http://www.küchenschöhn-not-working.de">www.küchenschöhn-not-working.de</a> URL' | ||||
| 			), | ||||
| 			array( | ||||
| 				'Text with a partial http://www.küchenschöhn-not-working.de URL', | ||||
| 				'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL' | ||||
| 			), | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -259,6 +347,16 @@ class TextHelperTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoLinkUrlsEscape() { | ||||
| 		$text = 'Text with a partial <a href="http://www.example.com">http://www.example.com</a> link'; | ||||
| 		$expected = 'Text with a partial <a href="http://www.example.com">http://www.example.com</a> link'; | ||||
| 		$result = $this->Text->autoLinkUrls($text, array('escape' => false)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'Text with a partial <a href="http://www.example.com">www.example.com</a> link'; | ||||
| 		$expected = 'Text with a partial <a href="http://www.example.com">www.example.com</a> link'; | ||||
| 		$result = $this->Text->autoLinkUrls($text, array('escape' => false)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'Text with a partial <a href="http://www.cakephp.org">link</a> link'; | ||||
| 		$expected = 'Text with a partial <a href="http://www.cakephp.org">link</a> link'; | ||||
| 		$result = $this->Text->autoLinkUrls($text, array('escape' => false)); | ||||
|  | @ -276,50 +374,115 @@ class TextHelperTest extends CakeTestCase { | |||
| 
 | ||||
| 		$text = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more'; | ||||
| 		$expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more'; | ||||
| 		$result = $this->Text->autoLinkUrls($text); | ||||
| 		$result = $this->Text->autoLinkUrls($text, array('escape' => true)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'Text with a url www.not-working-www.com and more'; | ||||
| 		$expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more'; | ||||
| 		$result = $this->Text->autoLinkUrls($text); | ||||
| 		$result = $this->Text->autoLinkUrls($text, array('escape' => false)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'Text with a url http://www.not-working-www.com and more'; | ||||
| 		$expected = 'Text with a url <a href="http://www.not-working-www.com">http://www.not-working-www.com</a> and more'; | ||||
| 		$result = $this->Text->autoLinkUrls($text); | ||||
| 		$result = $this->Text->autoLinkUrls($text, array('escape' => false)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'Text with a url http://www.www.not-working-www.com and more'; | ||||
| 		$expected = 'Text with a url <a href="http://www.www.not-working-www.com">http://www.www.not-working-www.com</a> and more'; | ||||
| 		$result = $this->Text->autoLinkUrls($text, array('escape' => false)); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test autoLinkUrls with query strings. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoLinkUrlsQueryString() { | ||||
| 		$text = 'Text with a partial http://www.cakephp.org?product_id=123&foo=bar link'; | ||||
| 		$expected = 'Text with a partial <a href="http://www.cakephp.org?product_id=123&foo=bar">http://www.cakephp.org?product_id=123&foo=bar</a> link'; | ||||
| 		$result = $this->Text->autoLinkUrls($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testAutoLinkEmails method | ||||
|  * Data provider for autoLinkEmail. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoLinkEmails() { | ||||
| 		$text = 'This is a test text'; | ||||
| 		$expected = 'This is a test text'; | ||||
| 		$result = $this->Text->autoLinkUrls($text); | ||||
| 	public function autoLinkEmailProvider() { | ||||
| 		return array( | ||||
| 			array( | ||||
| 				'This is a test text', | ||||
| 				'This is a test text', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'email@example.com address', | ||||
| 				'<a href="mailto:email@example.com">email@example.com</a> address', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'email@example.com address', | ||||
| 				'<a href="mailto:email@example.com">email@example.com</a> address', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'(email@example.com) address', | ||||
| 				'(<a href="mailto:email@example.com">email@example.com</a>) address', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'Text with email@example.com address', | ||||
| 				'Text with <a href="mailto:email@example.com">email@example.com</a> address', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				"Text with o'hare._-bob@example.com address", | ||||
| 				'Text with <a href="mailto:o'hare._-bob@example.com">o'hare._-bob@example.com</a> address', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'Text with düsentrieb@küchenschöhn-not-working.de address', | ||||
| 				'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'Text with me@subdomain.küchenschöhn.de address', | ||||
| 				'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address', | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'Text with email@example.com address', | ||||
| 				'Text with <a href="mailto:email@example.com" class="link">email@example.com</a> address', | ||||
| 				array('class' => 'link'), | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'<p>mark@example.com</p>', | ||||
| 				'<p><a href="mailto:mark@example.com">mark@example.com</a></p>', | ||||
| 				array('escape' => false) | ||||
| 			), | ||||
| 
 | ||||
| 			array( | ||||
| 				'Some mark@example.com Text', | ||||
| 				'Some <a href="mailto:mark@example.com">mark@example.com</a> Text', | ||||
| 				array('escape' => false) | ||||
| 			), | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testAutoLinkEmails method | ||||
|  * | ||||
|  * @param string $text The text to link | ||||
|  * @param string $expected The expected results. | ||||
|  * @dataProvider autoLinkEmailProvider | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoLinkEmails($text, $expected, $attrs = array()) { | ||||
| 		$result = $this->Text->autoLinkEmails($text, $attrs); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'Text with email@example.com address'; | ||||
| 		$expected = 'Text with <a href="mailto:email@example.com"\s*>email@example.com</a> address'; | ||||
| 		$result = $this->Text->autoLinkEmails($text); | ||||
| 		$this->assertRegExp('#^' . $expected . '$#', $result); | ||||
| 
 | ||||
| 		$text = "Text with o'hare._-bob@example.com address"; | ||||
| 		$expected = 'Text with <a href="mailto:o'hare._-bob@example.com">o'hare._-bob@example.com</a> address'; | ||||
| 		$result = $this->Text->autoLinkEmails($text); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$text = 'Text with email@example.com address'; | ||||
| 		$expected = 'Text with <a href="mailto:email@example.com" \s*class="link">email@example.com</a> address'; | ||||
| 		$result = $this->Text->autoLinkEmails($text, array('class' => 'link')); | ||||
| 		$this->assertRegExp('#^' . $expected . '$#', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -333,5 +496,58 @@ class TextHelperTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| /** | ||||
|  * testAutoParagraph method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoParagraph() { | ||||
| 		$text = 'This is a test text'; | ||||
| 		$expected = <<<TEXT | ||||
| <p>This is a test text</p> | ||||
| 
 | ||||
| TEXT; | ||||
| 		$result = $this->Text->autoParagraph($text); | ||||
| 		$text = 'This is a <br/> <BR> test text'; | ||||
| 		$expected = <<<TEXT | ||||
| <p>This is a </p> | ||||
| <p> test text</p> | ||||
| 
 | ||||
| TEXT; | ||||
| 		$result = $this->Text->autoParagraph($text); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 		$result = $this->Text->autoParagraph($text); | ||||
| 		$text = 'This is a <BR id="test"/><br class="test"> test text'; | ||||
| 		$expected = <<<TEXT | ||||
| <p>This is a </p> | ||||
| <p> test text</p> | ||||
| 
 | ||||
| TEXT; | ||||
| 		$result = $this->Text->autoParagraph($text); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 		$text = <<<TEXT | ||||
| This is a test text. | ||||
| This is a line return. | ||||
| TEXT; | ||||
| 		$expected = <<<TEXT | ||||
| <p>This is a test text.<br /> | ||||
| This is a line return.</p> | ||||
| 
 | ||||
| TEXT; | ||||
| 		$result = $this->Text->autoParagraph($text); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 		$text = <<<TEXT | ||||
| This is a test text. | ||||
| 
 | ||||
| This is a new line. | ||||
| TEXT; | ||||
| 		$expected = <<<TEXT | ||||
| <p>This is a test text.</p> | ||||
| <p>This is a new line.</p> | ||||
| 
 | ||||
| TEXT; | ||||
| 		$result = $this->Text->autoParagraph($text); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -2,26 +2,28 @@ | |||
| /** | ||||
|  * TimeHelperTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * 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. (http://cakefoundation.org) | ||||
|  * @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('TimeHelper', 'View/Helper'); | ||||
| App::uses('View', 'View'); | ||||
| App::uses('CakeTime', 'Utility'); | ||||
| 
 | ||||
| /** | ||||
|  * TimeHelperTestObject class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class TimeHelperTestObject extends TimeHelper { | ||||
| 
 | ||||
|  | @ -37,6 +39,8 @@ class TimeHelperTestObject extends TimeHelper { | |||
| 
 | ||||
| /** | ||||
|  * CakeTimeMock class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.View.Helper | ||||
|  */ | ||||
| class CakeTimeMock { | ||||
| } | ||||
|  | @ -74,6 +78,8 @@ class TimeHelperTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * test CakeTime class methods are called correctly | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testTimeHelperProxyMethodCalls() { | ||||
| 		$methods = array( | ||||
|  | @ -81,7 +87,7 @@ class TimeHelperTest extends CakeTestCase { | |||
| 			'nice', 'niceShort', 'daysAsSql', 'dayAsSql', | ||||
| 			'isToday', 'isThisMonth', 'isThisYear', 'wasYesterday', | ||||
| 			'isTomorrow', 'toQuarter', 'toUnix', 'toAtom', 'toRSS', | ||||
| 			'timeAgoInWords', 'wasWithinLast', 'gmt', 'format', 'i18nFormat', | ||||
| 			'wasWithinLast', 'gmt', 'format', 'i18nFormat', | ||||
| 		); | ||||
| 		$CakeTime = $this->getMock('CakeTimeMock', $methods); | ||||
| 		$Time = new TimeHelperTestObject($this->View, array('engine' => 'CakeTimeMock')); | ||||
|  | @ -90,10 +96,18 @@ class TimeHelperTest extends CakeTestCase { | |||
| 			$CakeTime->expects($this->at(0))->method($method); | ||||
| 			$Time->{$method}('who', 'what', 'when', 'where', 'how'); | ||||
| 		} | ||||
| 
 | ||||
| 		$CakeTime = $this->getMock('CakeTimeMock', array('timeAgoInWords')); | ||||
| 		$Time = new TimeHelperTestObject($this->View, array('engine' => 'CakeTimeMock')); | ||||
| 		$Time->attach($CakeTime); | ||||
| 		$CakeTime->expects($this->at(0))->method('timeAgoInWords'); | ||||
| 		$Time->timeAgoInWords('who', array('what'), array('when'), array('where'), array('how')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test engine override | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testEngineOverride() { | ||||
| 		App::build(array( | ||||
|  | @ -161,7 +175,7 @@ class TimeHelperTest extends CakeTestCase { | |||
| 				'title' => $timestamp, | ||||
| 				'class' => 'time-ago-in-words' | ||||
| 			), | ||||
| 			'2 weeks', | ||||
| 			'in 2 weeks', | ||||
| 			'/div' | ||||
| 		); | ||||
| 		$this->assertTags($result, $expected); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko