⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajax.test.php

📁 Cake Framwork , Excellent
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php/* SVN FILE: $Id: ajax.test.php 7118 2008-06-04 20:49:29Z gwoo $ *//** * Short description for file. * * Long description for file * * PHP versions 4 and 5 * * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite> * Copyright 2005-2008, Cake Software Foundation, Inc. *								1785 E. Sahara Avenue, Suite 490-204 *								Las Vegas, Nevada 89104 * *  Licensed under The Open Group Test Suite License *  Redistributions of files must retain the above copyright notice. * * @filesource * @copyright		Copyright 2005-2008, Cake Software Foundation, Inc. * @link				https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests * @package			cake.tests * @subpackage		cake.tests.cases.libs.view.helpers * @since			CakePHP(tm) v 1.2.0.4206 * @version			$Revision: 7118 $ * @modifiedby		$LastChangedBy: gwoo $ * @lastmodified	$Date: 2008-06-04 13:49:29 -0700 (Wed, 04 Jun 2008) $ * @license			http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {	define('CAKEPHP_UNIT_TEST_EXECUTION', 1);}uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'ajax',	'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form', 'view'.DS.'helpers'.DS.'javascript');/** * AjaxTestController class *  * @package              cake * @subpackage           cake.tests.cases.libs.view.helpers */class AjaxTestController extends Controller {/** * name property *  * @var string 'AjaxTest' * @access public */	var $name = 'AjaxTest';/** * uses property *  * @var mixed null * @access public */	var $uses = null;}/** * PostAjaxTest class *  * @package              cake * @subpackage           cake.tests.cases.libs.view.helpers */class PostAjaxTest extends Model {/** * primaryKey property *  * @var string 'id' * @access public */	var $primaryKey = 'id';/** * useTable property *  * @var bool false * @access public */	var $useTable = false;/** * schema method *  * @access public * @return void */	function schema() {		return array(			'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),			'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),			'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),			'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)		);	}}/** * TestAjaxHelper class *  * @package              cake * @subpackage           cake.tests.cases.libs.view.helpers */class TestAjaxHelper extends AjaxHelper {/** * stop method *  * @access public * @return void */	function _stop() {	}}/** * TestJavascriptHelper class *  * @package              cake * @subpackage           cake.tests.cases.libs.view.helpers */class TestJavascriptHelper extends JavascriptHelper {/** * codeBlocks property *  * @var mixed  * @access public */	var $codeBlocks;/** * codeBlock method *  * @param mixed $parameter  * @access public * @return void */	function codeBlock($parameter) {		if (empty($this->codeBlocks)) {			$this->codeBlocks = array();		}		$this->codeBlocks[] = $parameter;	}}/** * Short description for class. * * @package		cake.tests * @subpackage	cake.tests.cases.libs.view.helpers */class AjaxTest extends CakeTestCase {/** * setUp method *  * @access public * @return void */	function setUp() {		Router::reload();		$this->Ajax =& new TestAjaxHelper();		$this->Ajax->Html =& new HtmlHelper();		$this->Ajax->Form =& new FormHelper();		$this->Ajax->Javascript =& new JavascriptHelper();		$this->Ajax->Form->Html =& $this->Ajax->Html;		$view =& new View(new AjaxTestController());		ClassRegistry::addObject('view', $view);		ClassRegistry::addObject('PostAjaxTest', new PostAjaxTest());	}/** * testEvalScripts method *  * @access public * @return void */	function testEvalScripts() {		$result = $this->Ajax->link('Test Link', 'http://www.cakephp.org', array('id' => 'link1', 'update' => 'content', 'evalScripts' => false));		$this->assertPattern('/^<a\s+[^<>]+>Test Link<\/a><script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*' . str_replace('/', '\\/', preg_quote('Event.observe(\'link1\', \'click\', function(event) { new Ajax.Updater(\'content\',\'http://www.cakephp.org\', {asynchronous:true, evalScripts:false, requestHeaders:[\'X-Update\', \'content\']}) }, false);')) . '\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);		$this->assertPattern('/^<a\s+[^<>]*href="http:\/\/www.cakephp.org"[^<>]*>/', $result);		$this->assertPattern('/^<a\s+[^<>]*id="link1"[^<>]*>/', $result);		$this->assertPattern('/^<a\s+[^<>]*onclick="\s*' . str_replace('/', '\\/', preg_quote('event.returnValue = false; return false;')) . '\s*"[^<>]*>/', $result);		$result = $this->Ajax->link('Test Link', 'http://www.cakephp.org', array('id' => 'link1', 'update' => 'content'));		$this->assertPattern('/^<a\s+[^<>]+>Test Link<\/a><script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*' . str_replace('/', '\\/', preg_quote('Event.observe(\'link1\', \'click\', function(event) { new Ajax.Updater(\'content\',\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, requestHeaders:[\'X-Update\', \'content\']}) }, false);')) . '\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);		$this->assertPattern('/^<a\s+[^<>]*href="http:\/\/www.cakephp.org"[^<>]*>/', $result);		$this->assertPattern('/^<a\s+[^<>]*id="link1"[^<>]*>/', $result);		$this->assertPattern('/^<a\s+[^<>]*onclick="\s*' . str_replace('/', '\\/', preg_quote('event.returnValue = false; return false;')) . '\s*"[^<>]*>/', $result);	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -