mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge remote branch 'origin/2.0' into feature/2.0/pdo
This commit is contained in:
commit
25915bd931
42 changed files with 2102 additions and 3665 deletions
|
@ -143,13 +143,18 @@ if (!function_exists('sortByKey')) {
|
|||
* Convenience method for htmlspecialchars.
|
||||
*
|
||||
* @param string $text Text to wrap through htmlspecialchars
|
||||
* @param boolean $double Encode existing html entities
|
||||
* @param string $charset Character set to use when escaping. Defaults to config value in 'App.encoding' or 'UTF-8'
|
||||
* @return string Wrapped text
|
||||
* @link http://book.cakephp.org/view/1132/h
|
||||
*/
|
||||
function h($text, $charset = null) {
|
||||
function h($text, $double = true, $charset = null) {
|
||||
if (is_array($text)) {
|
||||
return array_map('h', $text);
|
||||
$texts = array();
|
||||
foreach ($text as $t) {
|
||||
$texts[] = h($t, $double, $charset);
|
||||
}
|
||||
return $texts;
|
||||
}
|
||||
|
||||
static $defaultCharset = false;
|
||||
|
@ -159,10 +164,13 @@ if (!function_exists('sortByKey')) {
|
|||
$defaultCharset = 'UTF-8';
|
||||
}
|
||||
}
|
||||
if (is_string($double)) {
|
||||
$charset = $double;
|
||||
}
|
||||
if ($charset) {
|
||||
return htmlspecialchars($text, ENT_QUOTES, $charset);
|
||||
return htmlspecialchars($text, ENT_QUOTES, $charset, $double);
|
||||
} else {
|
||||
return htmlspecialchars($text, ENT_QUOTES, $defaultCharset);
|
||||
return htmlspecialchars($text, ENT_QUOTES, $defaultCharset, $double);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ App::import('Component', 'Acl');
|
|||
App::import('Model', 'DbAcl');
|
||||
|
||||
/**
|
||||
* Shell for ACL management.
|
||||
* Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode
|
||||
* being enabled. Be sure to turn it off when using this shell.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.console.libs
|
||||
|
|
32
cake/libs/cache/memcache.php
vendored
32
cake/libs/cache/memcache.php
vendored
|
@ -80,12 +80,7 @@ class MemcacheEngine extends CacheEngine {
|
|||
$return = false;
|
||||
$this->__Memcache =& new Memcache();
|
||||
foreach ($this->settings['servers'] as $server) {
|
||||
$parts = explode(':', $server);
|
||||
$host = $parts[0];
|
||||
$port = 11211;
|
||||
if (isset($parts[1])) {
|
||||
$port = $parts[1];
|
||||
}
|
||||
list($host, $port) = $this->_parseServerString($server);
|
||||
if ($this->__Memcache->addServer($host, $port)) {
|
||||
$return = true;
|
||||
}
|
||||
|
@ -95,6 +90,31 @@ class MemcacheEngine extends CacheEngine {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the server address into the host/port. Handles both IPv6 and IPv4
|
||||
* addresses
|
||||
*
|
||||
* @param string $server The server address string.
|
||||
* @return array Array containing host, port
|
||||
*/
|
||||
function _parseServerString($server) {
|
||||
if (substr($server, 0, 1) == '[') {
|
||||
$position = strpos($server, ']:');
|
||||
if ($position !== false) {
|
||||
$position++;
|
||||
}
|
||||
} else {
|
||||
$position = strpos($server, ':');
|
||||
}
|
||||
$port = 11211;
|
||||
$host = $server;
|
||||
if ($position !== false) {
|
||||
$host = substr($server, 0, $position);
|
||||
$port = substr($server, $position + 1);
|
||||
}
|
||||
return array($host, $port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data for key into cache. When using memcache as your cache engine
|
||||
* remember that the Memcache pecl extension does not support cache expiry times greater
|
||||
|
|
|
@ -172,15 +172,15 @@ class RequestHandlerComponent extends Component {
|
|||
}
|
||||
|
||||
if ($this->requestedWith('xml')) {
|
||||
if (!class_exists('XmlNode')) {
|
||||
if (!class_exists('Xml')) {
|
||||
App::import('Core', 'Xml');
|
||||
}
|
||||
$xml = new Xml(trim(file_get_contents('php://input')));
|
||||
$xml = Xml::build(trim(file_get_contents('php://input')));
|
||||
|
||||
if (count($xml->children) == 1 && is_object($dataNode = $xml->child('data'))) {
|
||||
$controller->data = $dataNode->toArray();
|
||||
if (isset($xml->data)) {
|
||||
$controller->data = Xml::toArray($xml->data);
|
||||
} else {
|
||||
$controller->data = $xml->toArray();
|
||||
$controller->data = Xml::toArray($xml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -389,7 +389,7 @@ class SecurityComponent extends Component {
|
|||
$keys = array();
|
||||
$match = array();
|
||||
$req = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1);
|
||||
preg_match_all('@(\w+)=([\'"]?)([a-zA-Z0-9=./\_-]+)\2@', $digest, $match, PREG_SET_ORDER);
|
||||
preg_match_all('/(\w+)=([\'"]?)([a-zA-Z0-9@=.\/_-]+)\2/', $digest, $match, PREG_SET_ORDER);
|
||||
|
||||
foreach ($match as $i) {
|
||||
$keys[$i[1]] = $i[3];
|
||||
|
|
|
@ -98,7 +98,7 @@ class File {
|
|||
$this->name = basename($path);
|
||||
}
|
||||
$this->pwd();
|
||||
!$this->exists() && $create && $this->safe($path) && $this->create();
|
||||
$create && !$this->exists() && $this->safe($path) && $this->create();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -232,13 +232,21 @@ class CakeSchema extends Object {
|
|||
|
||||
if (is_array($models)) {
|
||||
foreach ($models as $model) {
|
||||
$importModel = $model;
|
||||
if (isset($this->plugin)) {
|
||||
$model = $this->plugin . '.' . $model;
|
||||
$importModel = $this->plugin . '.' . $model;
|
||||
}
|
||||
$Object = ClassRegistry::init(array('class' => $model, 'ds' => null));
|
||||
if (!App::import('Model', $importModel)) {
|
||||
continue;
|
||||
}
|
||||
$vars = get_class_vars($model);
|
||||
if (empty($vars['useDbConfig']) || $vars['useDbConfig'] != $connection) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$Object = ClassRegistry::init(array('class' => $model, 'ds' => $connection));
|
||||
|
||||
if (is_object($Object) && $Object->useTable !== false) {
|
||||
$Object->setDataSource($connection);
|
||||
$table = $db->fullTableName($Object, false);
|
||||
if (in_array($table, $currentTables)) {
|
||||
$key = array_search($table, $currentTables);
|
||||
|
|
|
@ -151,7 +151,7 @@ class DboSource extends DataSource {
|
|||
* @param array $config An array defining the new configuration settings
|
||||
* @return boolean True on success, false on failure
|
||||
*/
|
||||
public function reconnect($config = null) {
|
||||
function reconnect($config = array()) {
|
||||
$this->disconnect();
|
||||
$this->setConfig($config);
|
||||
$this->_sources = null;
|
||||
|
|
|
@ -1687,6 +1687,7 @@ class Model extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->__save($data, $options)) {
|
||||
$validationErrors[$this->alias] = $this->validationErrors;
|
||||
$validates = false;
|
||||
|
@ -1757,7 +1758,6 @@ class Model extends Object {
|
|||
case ($options['validate'] === 'first'):
|
||||
$options['validate'] = true;
|
||||
$return = array();
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
if ($options['atomic']) {
|
||||
|
@ -1770,6 +1770,10 @@ class Model extends Object {
|
|||
return $return;
|
||||
break;
|
||||
}
|
||||
if ($options['atomic'] && !$validates) {
|
||||
$db->rollback($this);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
@ -1821,14 +1825,15 @@ class Model extends Object {
|
|||
}
|
||||
$id = $this->id;
|
||||
|
||||
if ($this->exists() && $this->beforeDelete($cascade)) {
|
||||
$db = $this->getDataSource();
|
||||
if ($this->beforeDelete($cascade)) {
|
||||
$filters = $this->Behaviors->trigger($this, 'beforeDelete', array($cascade), array(
|
||||
'break' => true, 'breakOn' => false
|
||||
));
|
||||
if (!$filters) {
|
||||
if (!$filters || !$this->exists()) {
|
||||
return false;
|
||||
}
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
|
||||
$this->_deleteDependent($id, $cascade);
|
||||
$this->_deleteLinks($id);
|
||||
$this->id = $id;
|
||||
|
|
|
@ -85,6 +85,7 @@ class Sanitize {
|
|||
* - remove (boolean) if true strips all HTML tags before encoding
|
||||
* - charset (string) the charset used to encode the string
|
||||
* - quotes (int) see http://php.net/manual/en/function.htmlentities.php
|
||||
* - double (boolean) doube encode html entities
|
||||
*
|
||||
* @param string $string String from where to strip tags
|
||||
* @param array $options Array of options to use.
|
||||
|
@ -101,7 +102,8 @@ class Sanitize {
|
|||
$default = array(
|
||||
'remove' => false,
|
||||
'charset' => $defaultCharset,
|
||||
'quotes' => ENT_QUOTES
|
||||
'quotes' => ENT_QUOTES,
|
||||
'double' => true
|
||||
);
|
||||
|
||||
$options = array_merge($default, $options);
|
||||
|
@ -110,7 +112,7 @@ class Sanitize {
|
|||
$string = strip_tags($string);
|
||||
}
|
||||
|
||||
return htmlentities($string, $options['quotes'], $options['charset']);
|
||||
return htmlentities($string, $options['quotes'], $options['charset'], $options['double']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -368,11 +368,11 @@ class Set {
|
|||
$options = array_merge(array('flatten' => true), $options);
|
||||
if (!isset($contexts[0])) {
|
||||
$current = current($data);
|
||||
if ((is_array($current) && count($data) <= 1) || !is_array($current) || !Set::numeric(array_keys($data))) {
|
||||
if ((is_array($current) && count($data) < 1) || !is_array($current) || !Set::numeric(array_keys($data))) {
|
||||
$contexts = array($data);
|
||||
}
|
||||
}
|
||||
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z-]*\])/', $path), 1);
|
||||
$tokens = array_slice(preg_split('/(?<!=)\/(?![a-z-\s]*\])/', $path), 1);
|
||||
|
||||
do {
|
||||
$token = array_shift($tokens);
|
||||
|
@ -941,9 +941,8 @@ class Set {
|
|||
*/
|
||||
public static function reverse($object) {
|
||||
$out = array();
|
||||
if (is_a($object, 'XmlNode')) {
|
||||
$out = $object->toArray();
|
||||
return $out;
|
||||
if ($object instanceof SimpleXMLElement) {
|
||||
return Xml::toArray($object);
|
||||
} else if (is_object($object)) {
|
||||
$keys = get_object_vars($object);
|
||||
if (isset($keys['_name_'])) {
|
||||
|
|
|
@ -254,12 +254,14 @@ class FormHelper extends AppHelper {
|
|||
'plugin' => $this->plugin,
|
||||
'controller' => $this->_View->viewPath,
|
||||
'action' => $options['action'],
|
||||
0 => $id
|
||||
);
|
||||
if (!empty($options['action']) && !isset($options['id'])) {
|
||||
$options['id'] = $this->domId($options['action'] . 'Form');
|
||||
}
|
||||
$options['action'] = array_merge($actionDefaults, (array)$options['url']);
|
||||
if (empty($options['action'][0])) {
|
||||
$options['action'][0] = $id;
|
||||
}
|
||||
} elseif (is_string($options['url'])) {
|
||||
$options['action'] = $options['url'];
|
||||
}
|
||||
|
@ -582,7 +584,7 @@ class FormHelper extends AppHelper {
|
|||
*
|
||||
* In addition to fields control, inputs() allows you to use a few additional options.
|
||||
*
|
||||
* - `fieldset` Set to false to disable the fieldset. If a string is supplied it will be used as
|
||||
* - `fieldset` Set to false to disable the fieldset. If a string is supplied it will be used as
|
||||
* the classname for the fieldset element.
|
||||
* - `legend` Set to false to disable the legend for the generated input set. Or supply a string
|
||||
* to customize the legend text.
|
||||
|
@ -1078,7 +1080,7 @@ class FormHelper extends AppHelper {
|
|||
array('name', 'type', 'id'), '', ' '
|
||||
);
|
||||
$tagName = Inflector::camelize(
|
||||
$attributes['id'] . '_' . Inflector::underscore($optValue)
|
||||
$attributes['id'] . '_' . Inflector::slug($optValue)
|
||||
);
|
||||
|
||||
if ($label) {
|
||||
|
@ -1766,7 +1768,7 @@ class FormHelper extends AppHelper {
|
|||
* - `separator` The contents of the string between select elements. Defaults to '-'
|
||||
* - `empty` - If true, the empty select option is shown. If a string,
|
||||
* that string is displayed as the empty element.
|
||||
* - `value` | `default` The default value to be used by the input. A value in `$this->data`
|
||||
* - `value` | `default` The default value to be used by the input. A value in `$this->data`
|
||||
* matching the field name will override this value. If no default is provided `time()` will be used.
|
||||
*
|
||||
* @param string $fieldName Prefix name for the SELECT element
|
||||
|
@ -1986,6 +1988,7 @@ class FormHelper extends AppHelper {
|
|||
));
|
||||
|
||||
if (!empty($name)) {
|
||||
$name = $attributes['escape'] ? h($name) : $name;
|
||||
if ($attributes['style'] === 'checkbox') {
|
||||
$select[] = sprintf($this->Html->tags['fieldsetstart'], $name);
|
||||
} else {
|
||||
|
@ -2019,7 +2022,7 @@ class FormHelper extends AppHelper {
|
|||
$htmlOptions['value'] = $name;
|
||||
|
||||
$tagName = Inflector::camelize(
|
||||
$this->model() . '_' . $this->field().'_'.Inflector::underscore($name)
|
||||
$this->model() . '_' . $this->field().'_'.Inflector::slug($name)
|
||||
);
|
||||
$htmlOptions['id'] = $tagName;
|
||||
$label = array('for' => $tagName);
|
||||
|
|
|
@ -251,14 +251,13 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
|||
$options['url'] = $url;
|
||||
if (isset($options['update'])) {
|
||||
$wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
|
||||
if ($wrapCallbacks) {
|
||||
$success = $this->jQueryObject . '("' . $options['update'] . '").html(data);';
|
||||
} else {
|
||||
$success = sprintf(
|
||||
'function (data, textStatus) {%s("%s").html(data);}',
|
||||
$this->jQueryObject,
|
||||
$options['update']
|
||||
);
|
||||
$success = '';
|
||||
if(isset($options['success']) AND !empty($options['success'])) {
|
||||
$success .= $options['success'];
|
||||
}
|
||||
$success .= $this->jQueryObject . '("' . $options['update'] . '").html(data);';
|
||||
if (!$wrapCallbacks) {
|
||||
$success = 'function (data, textStatus) {' . $success . '}';
|
||||
}
|
||||
$options['dataType'] = 'html';
|
||||
$options['success'] = $success;
|
||||
|
|
|
@ -17,18 +17,16 @@
|
|||
* @since CakePHP(tm) v 1.2
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::import('Helper', 'Xml');
|
||||
App::import('Core', 'Xml');
|
||||
|
||||
/**
|
||||
* XML Helper class for easy output of XML structures.
|
||||
*
|
||||
* XmlHelper encloses all methods needed while working with XML documents.
|
||||
* RSS Helper class for easy output RSS structures.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1460/RSS
|
||||
*/
|
||||
class RssHelper extends XmlHelper {
|
||||
class RssHelper extends AppHelper {
|
||||
|
||||
/**
|
||||
* Helpers used by RSS Helper
|
||||
|
@ -270,7 +268,7 @@ class RssHelper extends XmlHelper {
|
|||
if (!empty($elements)) {
|
||||
$content = implode('', $elements);
|
||||
}
|
||||
return $this->elem('item', $att, $content, !($content === null));
|
||||
return $this->elem('item', (array)$att, $content, !($content === null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -283,4 +281,62 @@ class RssHelper extends XmlHelper {
|
|||
function time($time) {
|
||||
return $this->Time->toRSS($time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an XML element
|
||||
*
|
||||
* @param string $name The name of the XML element
|
||||
* @param array $attrib The attributes of the XML element
|
||||
* @param mixed $content XML element content
|
||||
* @param boolean $endTag Whether the end tag of the element should be printed
|
||||
* @return string XML
|
||||
*/
|
||||
function elem($name, $attrib = array(), $content = null, $endTag = true) {
|
||||
$namespace = null;
|
||||
if (isset($attrib['namespace'])) {
|
||||
$namespace = $attrib['namespace'];
|
||||
unset($attrib['namespace']);
|
||||
}
|
||||
$cdata = false;
|
||||
if (is_array($content) && isset($content['cdata'])) {
|
||||
$cdata = true;
|
||||
unset($content['cdata']);
|
||||
}
|
||||
if (is_array($content) && array_key_exists('value', $content)) {
|
||||
$content = $content['value'];
|
||||
}
|
||||
$children = array();
|
||||
if (is_array($content)) {
|
||||
$children = $content;
|
||||
$content = null;
|
||||
}
|
||||
|
||||
$xml = '<' . $name;
|
||||
if (!empty($namespace)) {
|
||||
$xml .= ' xmlns:"' . $namespace . '"';
|
||||
}
|
||||
if (strpos($name, ':') !== false) {
|
||||
list($prefix, ) = explode(':', $name, 2);
|
||||
switch ($prefix) {
|
||||
case 'atom':
|
||||
$xml .= ' xmlns:atom="http://www.w3.org/2005/Atom"';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($cdata && !empty($content)) {
|
||||
$content = '<![CDATA[' . $content . ']]>';
|
||||
}
|
||||
$xml .= '>' . $content . '</' . $name. '>';
|
||||
$elem = Xml::build($xml);
|
||||
foreach ($attrib as $key => $value) {
|
||||
$elem->addAttribute($key, $value);
|
||||
}
|
||||
foreach ($children as $child) {
|
||||
$elem->addChild($child);
|
||||
}
|
||||
|
||||
$xml = $elem->asXML();
|
||||
$xml = trim(substr($xml, strpos($xml, '?>') + 2));
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* XML Helper class file.
|
||||
*
|
||||
* Simplifies the output of XML documents.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @since CakePHP(tm) v 1.2
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::import('Core', array('Xml', 'Set'));
|
||||
|
||||
/**
|
||||
* XML Helper class for easy output of XML structures.
|
||||
*
|
||||
* XmlHelper encloses all methods needed while working with XML documents.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.view.helpers
|
||||
* @link http://book.cakephp.org/view/1473/XML
|
||||
*/
|
||||
class XmlHelper extends AppHelper {
|
||||
|
||||
/**
|
||||
* Default document encoding
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $encoding = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Xml instance
|
||||
*
|
||||
* @var Xml
|
||||
*/
|
||||
public $Xml;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function __construct(View $View, $settings = array()) {
|
||||
parent::__construct($View, $settings);
|
||||
$this->Xml =& new Xml();
|
||||
$this->Xml->options(array('verifyNs' => false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an XML document header
|
||||
*
|
||||
* @param array $attrib Header tag attributes
|
||||
* @return string XML header
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1476/header
|
||||
*/
|
||||
public function header($attrib = array()) {
|
||||
if (Configure::read('App.encoding') !== null) {
|
||||
$this->encoding = Configure::read('App.encoding');
|
||||
}
|
||||
|
||||
if (is_array($attrib)) {
|
||||
$attrib = array_merge(array('encoding' => $this->encoding), $attrib);
|
||||
}
|
||||
if (is_string($attrib) && strpos($attrib, 'xml') !== 0) {
|
||||
$attrib = 'xml ' . $attrib;
|
||||
}
|
||||
|
||||
return $this->Xml->header($attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a namespace to any documents generated
|
||||
*
|
||||
* @param string $name The namespace name
|
||||
* @param string $url The namespace URI; can be empty if in the default namespace map
|
||||
* @return boolean False if no URL is specified, and the namespace does not exist
|
||||
* default namespace map, otherwise true
|
||||
* @deprecated
|
||||
* @see Xml::addNs()
|
||||
*/
|
||||
function addNs($name, $url = null) {
|
||||
return $this->Xml->addNamespace($name, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a namespace added in addNs()
|
||||
*
|
||||
* @param string $name The namespace name or URI
|
||||
* @deprecated
|
||||
* @see Xml::removeNs()
|
||||
*/
|
||||
public function removeNs($name) {
|
||||
return $this->Xml->removeGlobalNamespace($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an XML element
|
||||
*
|
||||
* @param string $name The name of the XML element
|
||||
* @param array $attrib The attributes of the XML element
|
||||
* @param mixed $content XML element content
|
||||
* @param boolean $endTag Whether the end tag of the element should be printed
|
||||
* @return string XML
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1475/elem
|
||||
*/
|
||||
public function elem($name, $attrib = array(), $content = null, $endTag = true) {
|
||||
$namespace = null;
|
||||
if (isset($attrib['namespace'])) {
|
||||
$namespace = $attrib['namespace'];
|
||||
unset($attrib['namespace']);
|
||||
}
|
||||
$cdata = false;
|
||||
if (is_array($content) && isset($content['cdata'])) {
|
||||
$cdata = true;
|
||||
unset($content['cdata']);
|
||||
}
|
||||
if (is_array($content) && array_key_exists('value', $content)) {
|
||||
$content = $content['value'];
|
||||
}
|
||||
$children = array();
|
||||
if (is_array($content)) {
|
||||
$children = $content;
|
||||
$content = null;
|
||||
}
|
||||
|
||||
$elem =& $this->Xml->createElement($name, $content, $attrib, $namespace);
|
||||
foreach ($children as $child) {
|
||||
$elem->createElement($child);
|
||||
}
|
||||
$out = $elem->toString(array('cdata' => $cdata, 'leaveOpen' => !$endTag));
|
||||
|
||||
if (!$endTag) {
|
||||
$this->Xml =& $elem;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create closing tag for current element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function closeElem() {
|
||||
$name = $this->Xml->name();
|
||||
if ($parent =& $this->Xml->parent()) {
|
||||
$this->Xml =& $parent;
|
||||
}
|
||||
return '</' . $name . '>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a model resultset into XML
|
||||
*
|
||||
* @param mixed $data The content to be converted to XML
|
||||
* @param array $options The data formatting options. For a list of valid options, see
|
||||
* Xml::__construct().
|
||||
* @return string A copy of $data in XML format
|
||||
* @see Xml::__construct()
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1474/serialize
|
||||
*/
|
||||
public function serialize($data, $options = array()) {
|
||||
$options += array('attributes' => false, 'format' => 'attributes');
|
||||
$data =& new Xml($data, $options);
|
||||
return $data->toString($options + array('header' => false));
|
||||
}
|
||||
}
|
|
@ -390,8 +390,8 @@ class View extends Object {
|
|||
if ($layout && $this->autoLayout) {
|
||||
$out = $this->renderLayout($out, $layout);
|
||||
$isCached = (
|
||||
isset($this->Helpers->Cache) &&
|
||||
(($this->cacheAction != false)) && (Configure::read('Cache.check') === true)
|
||||
isset($this->Helpers->Cache) ||
|
||||
Configure::read('Cache.check') === true
|
||||
);
|
||||
|
||||
if ($isCached) {
|
||||
|
@ -562,6 +562,7 @@ class View extends Object {
|
|||
if (
|
||||
($count == 1 && !empty($this->association)) ||
|
||||
($count == 1 && $this->model != $this->entityPath) ||
|
||||
($count == 1 && empty($this->association) && !empty($this->field)) ||
|
||||
($count == 2 && !empty($this->fieldSuffix)) ||
|
||||
is_numeric($path[0]) && !empty($assoc)
|
||||
) {
|
||||
|
|
1610
cake/libs/xml.php
1610
cake/libs/xml.php
File diff suppressed because it is too large
Load diff
|
@ -200,6 +200,34 @@ class BasicsTest extends CakeTestCase {
|
|||
$result = h($in);
|
||||
$expected = array('this & that', '<p>Which one</p>');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$string = '<foo> & ';
|
||||
$result = h($string);
|
||||
$this->assertEqual('<foo> & &nbsp;', $result);
|
||||
|
||||
$string = '<foo> & ';
|
||||
$result = h($string, false);
|
||||
$this->assertEqual('<foo> & ', $result);
|
||||
|
||||
$string = '<foo> & ';
|
||||
$result = h($string, 'UTF-8');
|
||||
$this->assertEqual('<foo> & &nbsp;', $result);
|
||||
|
||||
$arr = array('<foo>', ' ');
|
||||
$result = h($arr);
|
||||
$expected = array(
|
||||
'<foo>',
|
||||
'&nbsp;'
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$arr = array('<foo>', ' ');
|
||||
$result = h($arr, false);
|
||||
$expected = array(
|
||||
'<foo>',
|
||||
' '
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,6 @@ class AllXmlTest extends PHPUnit_Framework_TestSuite {
|
|||
|
||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'xml.test.php');
|
||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS . 'rss.test.php');
|
||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS . 'xml.test.php');
|
||||
return $suite;
|
||||
}
|
||||
}
|
46
cake/tests/cases/libs/cache/memcache.test.php
vendored
46
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -20,6 +20,20 @@
|
|||
if (!class_exists('Cache')) {
|
||||
require LIBS . 'cache.php';
|
||||
}
|
||||
App::import('Core', 'cache/Memcache');
|
||||
|
||||
|
||||
class TestMemcacheEngine extends MemcacheEngine {
|
||||
/**
|
||||
* public accessor to _parseServerString
|
||||
*
|
||||
* @param string $server
|
||||
* @return array
|
||||
*/
|
||||
function parseServerString($server) {
|
||||
return $this->_parseServerString($server);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MemcacheEngineTest class
|
||||
|
@ -121,6 +135,38 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test connecting to an ipv6 server.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testConnectIpv6() {
|
||||
$Memcache =& new MemcacheEngine();
|
||||
$result = $Memcache->init(array(
|
||||
'prefix' => 'cake_',
|
||||
'duration' => 200,
|
||||
'engine' => 'Memcache',
|
||||
'servers' => array(
|
||||
'[::1]:11211'
|
||||
)
|
||||
));
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test non latin domains.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testParseServerStringNonLatin() {
|
||||
$Memcache =& new TestMemcacheEngine();
|
||||
$result = $Memcache->parseServerString('schülervz.net:13211');
|
||||
$this->assertEqual($result, array('schülervz.net', '13211'));
|
||||
|
||||
$result = $Memcache->parseServerString('sülül:1111');
|
||||
$this->assertEqual($result, array('sülül', '1111'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testReadAndWriteCache method
|
||||
*
|
||||
|
|
|
@ -565,7 +565,15 @@ class AppImportTest extends CakeTestCase {
|
|||
$this->assertTrue($file);
|
||||
$this->assertTrue(class_exists('DboSource'));
|
||||
}
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* test import() with plugins
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testPluginImporting() {
|
||||
App::build(array(
|
||||
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
|
||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
|
@ -587,10 +595,15 @@ class AppImportTest extends CakeTestCase {
|
|||
$result = App::import('Helper', 'TestPlugin.OtherHelper');
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(class_exists('OtherHelperHelper'));
|
||||
|
||||
$result = App::import('Helper', 'TestPlugin.TestPluginApp');
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(class_exists('TestPluginAppHelper'));
|
||||
|
||||
$result = App::import('Datasource', 'TestPlugin.TestSource');
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(class_exists('TestSource'));
|
||||
|
||||
App::build();
|
||||
}
|
||||
|
||||
|
|
|
@ -331,11 +331,11 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testRenderAs() {
|
||||
$this->assertFalse(in_array('Xml', $this->Controller->helpers));
|
||||
$this->RequestHandler->renderAs($this->Controller, 'xml');
|
||||
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
|
||||
$this->assertFalse(in_array('Rss', $this->Controller->helpers));
|
||||
$this->RequestHandler->renderAs($this->Controller, 'rss');
|
||||
$this->assertTrue(in_array('Rss', $this->Controller->helpers));
|
||||
|
||||
$this->Controller->viewPath = 'request_handler_test\\xml';
|
||||
$this->Controller->viewPath = 'request_handler_test\\rss';
|
||||
$this->RequestHandler->renderAs($this->Controller, 'js');
|
||||
$this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js');
|
||||
}
|
||||
|
@ -425,8 +425,6 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'xml');
|
||||
$this->assertEqual($this->Controller->layoutPath, 'xml');
|
||||
|
||||
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
|
||||
|
||||
$this->RequestHandler->renderAs($this->Controller, 'js');
|
||||
$this->assertEqual($this->Controller->viewPath, 'request_handler_test' . DS . 'js');
|
||||
$this->assertEqual($this->Controller->layoutPath, 'js');
|
||||
|
|
|
@ -1054,6 +1054,7 @@ DIGEST;
|
|||
DIGEST;
|
||||
$expected = array(
|
||||
'username' => 'Mufasa',
|
||||
'realm' => 'testrealm@host.com',
|
||||
'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
|
||||
'uri' => '/dir/index.html',
|
||||
'qop' => 'auth',
|
||||
|
@ -1088,6 +1089,7 @@ DIGEST;
|
|||
DIGEST;
|
||||
$expected = array(
|
||||
'username' => 'Mufasa',
|
||||
'realm' => 'testrealm@host.com',
|
||||
'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
|
||||
'uri' => '/dir/index.html',
|
||||
'qop' => 'auth',
|
||||
|
@ -1103,6 +1105,39 @@ DIGEST;
|
|||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test parsing digest information with email addresses
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testParseDigestAuthEmailAddress() {
|
||||
$this->Controller->Security->startup($this->Controller);
|
||||
$digest = <<<DIGEST
|
||||
Digest username="mark@example.com",
|
||||
realm="testrealm@host.com",
|
||||
nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
|
||||
uri="/dir/index.html",
|
||||
qop=auth,
|
||||
nc=00000001,
|
||||
cnonce="0a4f113b",
|
||||
response="6629fae49393a05397450978507c4ef1",
|
||||
opaque="5ccc069c403ebaf9f0171e9517f40e41"
|
||||
DIGEST;
|
||||
$expected = array(
|
||||
'username' => 'mark@example.com',
|
||||
'realm' => 'testrealm@host.com',
|
||||
'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093',
|
||||
'uri' => '/dir/index.html',
|
||||
'qop' => 'auth',
|
||||
'nc' => '00000001',
|
||||
'cnonce' => '0a4f113b',
|
||||
'response' => '6629fae49393a05397450978507c4ef1',
|
||||
'opaque' => '5ccc069c403ebaf9f0171e9517f40e41'
|
||||
);
|
||||
$result = $this->Controller->Security->parseDigestAuthData($digest);
|
||||
$this->assertIdentical($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testFormDisabledFields method
|
||||
*
|
||||
|
|
|
@ -680,17 +680,17 @@ class CakeSchemaTest extends CakeTestCase {
|
|||
'name' => 'TestApp',
|
||||
'models' => array('SchemaCrossDatabase', 'SchemaPost')
|
||||
));
|
||||
unset($read['tables']['missing']);
|
||||
$this->assertTrue(isset($read['tables']['posts']));
|
||||
$this->assertFalse(isset($read['tables']['cross_database']));
|
||||
$this->assertFalse(isset($read['tables']['cross_database']), 'Cross database should not appear');
|
||||
$this->assertFalse(isset($read['tables']['missing']['cross_database']), 'Cross database should not appear');
|
||||
|
||||
$read = $this->Schema->read(array(
|
||||
'connection' => 'test2',
|
||||
'name' => 'TestApp',
|
||||
'models' => array('SchemaCrossDatabase', 'SchemaPost')
|
||||
));
|
||||
unset($read['tables']['missing']);
|
||||
$this->assertFalse(isset($read['tables']['posts']));
|
||||
$this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear');
|
||||
$this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear');
|
||||
$this->assertTrue(isset($read['tables']['cross_database']));
|
||||
|
||||
$fixture->drop($db2);
|
||||
|
|
|
@ -267,446 +267,489 @@ class ModelDeleteTest extends BaseModelTest {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* test that delete() updates the correct records counterCache() records.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteUpdatingCounterCacheCorrectly() {
|
||||
$this->loadFixtures('CounterCacheUser', 'CounterCachePost');
|
||||
$User = new CounterCacheUser();
|
||||
/**
|
||||
* test that delete() updates the correct records counterCache() records.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteUpdatingCounterCacheCorrectly() {
|
||||
$this->loadFixtures('CounterCacheUser', 'CounterCachePost');
|
||||
$User = new CounterCacheUser();
|
||||
|
||||
$User->Post->delete(3);
|
||||
$result = $User->read(null, 301);
|
||||
$this->assertEqual($result['User']['post_count'], 0);
|
||||
$User->Post->delete(3);
|
||||
$result = $User->read(null, 301);
|
||||
$this->assertEqual($result['User']['post_count'], 0);
|
||||
|
||||
$result = $User->read(null, 66);
|
||||
$this->assertEqual($result['User']['post_count'], 2);
|
||||
}
|
||||
$result = $User->read(null, 66);
|
||||
$this->assertEqual($result['User']['post_count'], 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* testDeleteAll method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteAll() {
|
||||
$this->loadFixtures('Article');
|
||||
$TestModel = new Article();
|
||||
/**
|
||||
* testDeleteAll method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteAll() {
|
||||
$this->loadFixtures('Article');
|
||||
$TestModel = new Article();
|
||||
|
||||
$data = array('Article' => array(
|
||||
'user_id' => 2,
|
||||
$data = array('Article' => array(
|
||||
'user_id' => 2,
|
||||
'id' => 4,
|
||||
'title' => 'Fourth Article',
|
||||
'published' => 'N'
|
||||
));
|
||||
$result = $TestModel->set($data) && $TestModel->save();
|
||||
$this->assertTrue($result);
|
||||
|
||||
$data = array('Article' => array(
|
||||
'user_id' => 2,
|
||||
'id' => 5,
|
||||
'title' => 'Fifth Article',
|
||||
'published' => 'Y'
|
||||
));
|
||||
$result = $TestModel->set($data) && $TestModel->save();
|
||||
$this->assertTrue($result);
|
||||
|
||||
$data = array('Article' => array(
|
||||
'user_id' => 1,
|
||||
'id' => 6,
|
||||
'title' => 'Sixth Article',
|
||||
'published' => 'N'
|
||||
));
|
||||
$result = $TestModel->set($data) && $TestModel->save();
|
||||
$this->assertTrue($result);
|
||||
|
||||
$TestModel->recursive = -1;
|
||||
$result = $TestModel->find('all', array(
|
||||
'fields' => array('id', 'user_id', 'title', 'published')
|
||||
));
|
||||
|
||||
$expected = array(
|
||||
array('Article' => array(
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'title' => 'First Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 2,
|
||||
'user_id' => 3,
|
||||
'title' => 'Second Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 3,
|
||||
'user_id' => 1,
|
||||
'title' => 'Third Article',
|
||||
'published' => 'Y')),
|
||||
array('Article' => array(
|
||||
'id' => 4,
|
||||
'user_id' => 2,
|
||||
'title' => 'Fourth Article',
|
||||
'published' => 'N'
|
||||
));
|
||||
$result = $TestModel->set($data) && $TestModel->save();
|
||||
$this->assertTrue($result);
|
||||
|
||||
$data = array('Article' => array(
|
||||
'user_id' => 2,
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 5,
|
||||
'user_id' => 2,
|
||||
'title' => 'Fifth Article',
|
||||
'published' => 'Y'
|
||||
));
|
||||
$result = $TestModel->set($data) && $TestModel->save();
|
||||
$this->assertTrue($result);
|
||||
|
||||
$data = array('Article' => array(
|
||||
'user_id' => 1,
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 6,
|
||||
'user_id' => 1,
|
||||
'title' => 'Sixth Article',
|
||||
'published' => 'N'
|
||||
));
|
||||
$result = $TestModel->set($data) && $TestModel->save();
|
||||
$this->assertTrue($result);
|
||||
)));
|
||||
|
||||
$TestModel->recursive = -1;
|
||||
$result = $TestModel->find('all', array(
|
||||
'fields' => array('id', 'user_id', 'title', 'published')
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected = array(
|
||||
array('Article' => array(
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'title' => 'First Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 2,
|
||||
'user_id' => 3,
|
||||
'title' => 'Second Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 3,
|
||||
'user_id' => 1,
|
||||
'title' => 'Third Article',
|
||||
'published' => 'Y')),
|
||||
array('Article' => array(
|
||||
'id' => 4,
|
||||
'user_id' => 2,
|
||||
'title' => 'Fourth Article',
|
||||
'published' => 'N'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 5,
|
||||
'user_id' => 2,
|
||||
'title' => 'Fifth Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 6,
|
||||
'user_id' => 1,
|
||||
'title' => 'Sixth Article',
|
||||
'published' => 'N'
|
||||
)));
|
||||
$result = $TestModel->deleteAll(array('Article.published' => 'N'));
|
||||
$this->assertTrue($result);
|
||||
|
||||
$this->assertEqual($result, $expected);
|
||||
$TestModel->recursive = -1;
|
||||
$result = $TestModel->find('all', array(
|
||||
'fields' => array('id', 'user_id', 'title', 'published')
|
||||
));
|
||||
$expected = array(
|
||||
array('Article' => array(
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'title' => 'First Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 2,
|
||||
'user_id' => 3,
|
||||
'title' => 'Second Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 3,
|
||||
'user_id' => 1,
|
||||
'title' => 'Third Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 5,
|
||||
'user_id' => 2,
|
||||
'title' => 'Fifth Article',
|
||||
'published' => 'Y'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $TestModel->deleteAll(array('Article.published' => 'N'));
|
||||
$this->assertTrue($result);
|
||||
$data = array('Article.user_id' => array(2, 3));
|
||||
$result = $TestModel->deleteAll($data, true, true);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$TestModel->recursive = -1;
|
||||
$result = $TestModel->find('all', array(
|
||||
'fields' => array('id', 'user_id', 'title', 'published')
|
||||
));
|
||||
$expected = array(
|
||||
array('Article' => array(
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'title' => 'First Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 2,
|
||||
'user_id' => 3,
|
||||
'title' => 'Second Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 3,
|
||||
'user_id' => 1,
|
||||
'title' => 'Third Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 5,
|
||||
'user_id' => 2,
|
||||
'title' => 'Fifth Article',
|
||||
'published' => 'Y'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
$TestModel->recursive = -1;
|
||||
$result = $TestModel->find('all', array(
|
||||
'fields' => array('id', 'user_id', 'title', 'published')
|
||||
));
|
||||
$expected = array(
|
||||
array('Article' => array(
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'title' => 'First Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 3,
|
||||
'user_id' => 1,
|
||||
'title' => 'Third Article',
|
||||
'published' => 'Y'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$data = array('Article.user_id' => array(2, 3));
|
||||
$result = $TestModel->deleteAll($data, true, true);
|
||||
$this->assertTrue($result);
|
||||
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
|
||||
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
|
||||
|
||||
$TestModel->recursive = -1;
|
||||
$result = $TestModel->find('all', array(
|
||||
'fields' => array('id', 'user_id', 'title', 'published')
|
||||
));
|
||||
$expected = array(
|
||||
array('Article' => array(
|
||||
'id' => 1,
|
||||
'user_id' => 1,
|
||||
'title' => 'First Article',
|
||||
'published' => 'Y'
|
||||
)),
|
||||
array('Article' => array(
|
||||
'id' => 3,
|
||||
'user_id' => 1,
|
||||
'title' => 'Third Article',
|
||||
'published' => 'Y'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->expectError();
|
||||
ob_start();
|
||||
$result = $TestModel->deleteAll(array('Article.non_existent_field' => 999));
|
||||
ob_get_clean();
|
||||
$this->assertFalse($result, 'deleteAll returned true when find query generated sql error. %s');
|
||||
}
|
||||
|
||||
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
|
||||
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
|
||||
/**
|
||||
* testRecursiveDel method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRecursiveDel() {
|
||||
$this->loadFixtures('Article', 'Comment', 'Attachment');
|
||||
$TestModel = new Article();
|
||||
|
||||
$this->expectError();
|
||||
ob_start();
|
||||
$result = $TestModel->deleteAll(array('Article.non_existent_field' => 999));
|
||||
ob_get_clean();
|
||||
$this->assertFalse($result, 'deleteAll returned true when find query generated sql error. %s');
|
||||
}
|
||||
$result = $TestModel->delete(2);
|
||||
$this->assertTrue($result);
|
||||
|
||||
/**
|
||||
* testRecursiveDel method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRecursiveDel() {
|
||||
$this->loadFixtures('Article', 'Comment', 'Attachment');
|
||||
$TestModel = new Article();
|
||||
$TestModel->recursive = 2;
|
||||
$result = $TestModel->read(null, 2);
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $TestModel->delete(2);
|
||||
$this->assertTrue($result);
|
||||
$result = $TestModel->Comment->read(null, 5);
|
||||
$this->assertFalse($result);
|
||||
|
||||
$TestModel->recursive = 2;
|
||||
$result = $TestModel->read(null, 2);
|
||||
$this->assertFalse($result);
|
||||
$result = $TestModel->Comment->read(null, 6);
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $TestModel->Comment->read(null, 5);
|
||||
$this->assertFalse($result);
|
||||
$result = $TestModel->Comment->Attachment->read(null, 1);
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $TestModel->Comment->read(null, 6);
|
||||
$this->assertFalse($result);
|
||||
$result = $TestModel->find('count');
|
||||
$this->assertEqual($result, 2);
|
||||
|
||||
$result = $TestModel->Comment->Attachment->read(null, 1);
|
||||
$this->assertFalse($result);
|
||||
$result = $TestModel->Comment->find('count');
|
||||
$this->assertEqual($result, 4);
|
||||
|
||||
$result = $TestModel->find('count');
|
||||
$this->assertEqual($result, 2);
|
||||
$result = $TestModel->Comment->Attachment->find('count');
|
||||
$this->assertEqual($result, 0);
|
||||
}
|
||||
|
||||
$result = $TestModel->Comment->find('count');
|
||||
$this->assertEqual($result, 4);
|
||||
/**
|
||||
* testDependentExclusiveDelete method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDependentExclusiveDelete() {
|
||||
$this->loadFixtures('Article', 'Comment');
|
||||
$TestModel = new Article10();
|
||||
|
||||
$result = $TestModel->Comment->Attachment->find('count');
|
||||
$this->assertEqual($result, 0);
|
||||
}
|
||||
$result = $TestModel->find('all');
|
||||
$this->assertEqual(count($result[0]['Comment']), 4);
|
||||
$this->assertEqual(count($result[1]['Comment']), 2);
|
||||
$this->assertEqual($TestModel->Comment->find('count'), 6);
|
||||
|
||||
/**
|
||||
* testDependentExclusiveDelete method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDependentExclusiveDelete() {
|
||||
$this->loadFixtures('Article', 'Comment');
|
||||
$TestModel = new Article10();
|
||||
$TestModel->delete(1);
|
||||
$this->assertEqual($TestModel->Comment->find('count'), 2);
|
||||
}
|
||||
|
||||
$result = $TestModel->find('all');
|
||||
$this->assertEqual(count($result[0]['Comment']), 4);
|
||||
$this->assertEqual(count($result[1]['Comment']), 2);
|
||||
$this->assertEqual($TestModel->Comment->find('count'), 6);
|
||||
/**
|
||||
* testDeleteLinks method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteLinks() {
|
||||
$this->loadFixtures('Article', 'ArticlesTag', 'Tag');
|
||||
$TestModel = new Article();
|
||||
|
||||
$TestModel->delete(1);
|
||||
$this->assertEqual($TestModel->Comment->find('count'), 2);
|
||||
}
|
||||
$result = $TestModel->ArticlesTag->find('all');
|
||||
$expected = array(
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '1',
|
||||
'tag_id' => '1'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '1',
|
||||
'tag_id' => '2'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '1'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '3'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
/**
|
||||
* testDeleteLinks method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteLinks() {
|
||||
$this->loadFixtures('Article', 'ArticlesTag', 'Tag');
|
||||
$TestModel = new Article();
|
||||
$TestModel->delete(1);
|
||||
$result = $TestModel->ArticlesTag->find('all');
|
||||
|
||||
$result = $TestModel->ArticlesTag->find('all');
|
||||
$expected = array(
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '1',
|
||||
'tag_id' => '1'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '1',
|
||||
'tag_id' => '2'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '1'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '3'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
$expected = array(
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '1'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '3'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$TestModel->delete(1);
|
||||
$result = $TestModel->ArticlesTag->find('all');
|
||||
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
|
||||
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
|
||||
}
|
||||
|
||||
$expected = array(
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '1'
|
||||
)),
|
||||
array('ArticlesTag' => array(
|
||||
'article_id' => '2',
|
||||
'tag_id' => '3'
|
||||
)));
|
||||
$this->assertEqual($result, $expected);
|
||||
/**
|
||||
* test deleteLinks with Multiple habtm associations
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteLinksWithMultipleHabtmAssociations() {
|
||||
$this->loadFixtures('JoinA', 'JoinB', 'JoinC', 'JoinAB', 'JoinAC');
|
||||
$JoinA = new JoinA();
|
||||
|
||||
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
|
||||
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
|
||||
}
|
||||
//create two new join records to expose the issue.
|
||||
$JoinA->JoinAsJoinC->create(array(
|
||||
'join_a_id' => 1,
|
||||
'join_c_id' => 2,
|
||||
));
|
||||
$JoinA->JoinAsJoinC->save();
|
||||
$JoinA->JoinAsJoinB->create(array(
|
||||
'join_a_id' => 1,
|
||||
'join_b_id' => 2,
|
||||
));
|
||||
$JoinA->JoinAsJoinB->save();
|
||||
|
||||
/**
|
||||
* test deleteLinks with Multiple habtm associations
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteLinksWithMultipleHabtmAssociations() {
|
||||
$this->loadFixtures('JoinA', 'JoinB', 'JoinC', 'JoinAB', 'JoinAC');
|
||||
$JoinA = new JoinA();
|
||||
$result = $JoinA->delete(1);
|
||||
$this->assertTrue($result, 'Delete failed %s');
|
||||
|
||||
//create two new join records to expose the issue.
|
||||
$JoinA->JoinAsJoinC->create(array(
|
||||
'join_a_id' => 1,
|
||||
'join_c_id' => 2,
|
||||
));
|
||||
$JoinA->JoinAsJoinC->save();
|
||||
$JoinA->JoinAsJoinB->create(array(
|
||||
'join_a_id' => 1,
|
||||
'join_b_id' => 2,
|
||||
));
|
||||
$JoinA->JoinAsJoinB->save();
|
||||
$joinedBs = $JoinA->JoinAsJoinB->find('count', array(
|
||||
'conditions' => array('JoinAsJoinB.join_a_id' => 1)
|
||||
));
|
||||
$this->assertEqual($joinedBs, 0, 'JoinA/JoinB link records left over. %s');
|
||||
|
||||
$result = $JoinA->delete(1);
|
||||
$this->assertTrue($result, 'Delete failed %s');
|
||||
$joinedBs = $JoinA->JoinAsJoinC->find('count', array(
|
||||
'conditions' => array('JoinAsJoinC.join_a_id' => 1)
|
||||
));
|
||||
$this->assertEqual($joinedBs, 0, 'JoinA/JoinC link records left over. %s');
|
||||
}
|
||||
|
||||
$joinedBs = $JoinA->JoinAsJoinB->find('count', array(
|
||||
'conditions' => array('JoinAsJoinB.join_a_id' => 1)
|
||||
));
|
||||
$this->assertEqual($joinedBs, 0, 'JoinA/JoinB link records left over. %s');
|
||||
/**
|
||||
* testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable() {
|
||||
|
||||
$joinedBs = $JoinA->JoinAsJoinC->find('count', array(
|
||||
'conditions' => array('JoinAsJoinC.join_a_id' => 1)
|
||||
));
|
||||
$this->assertEqual($joinedBs, 0, 'JoinA/JoinC link records left over. %s');
|
||||
}
|
||||
$this->loadFixtures('Apple', 'Device', 'ThePaperMonkies');
|
||||
$ThePaper = new ThePaper();
|
||||
$ThePaper->id = 1;
|
||||
$ThePaper->save(array('Monkey' => array(2, 3)));
|
||||
|
||||
/**
|
||||
* testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable() {
|
||||
$result = $ThePaper->findById(1);
|
||||
$expected = array(
|
||||
array(
|
||||
'id' => '2',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 2',
|
||||
'typ' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => '3',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 3',
|
||||
'typ' => '2'
|
||||
));
|
||||
$this->assertEqual($result['Monkey'], $expected);
|
||||
|
||||
$this->loadFixtures('Apple', 'Device', 'ThePaperMonkies');
|
||||
$ThePaper = new ThePaper();
|
||||
$ThePaper->id = 1;
|
||||
$ThePaper->save(array('Monkey' => array(2, 3)));
|
||||
$ThePaper = new ThePaper();
|
||||
$ThePaper->id = 2;
|
||||
$ThePaper->save(array('Monkey' => array(2, 3)));
|
||||
|
||||
$result = $ThePaper->findById(1);
|
||||
$expected = array(
|
||||
array(
|
||||
'id' => '2',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 2',
|
||||
'typ' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => '3',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 3',
|
||||
'typ' => '2'
|
||||
));
|
||||
$this->assertEqual($result['Monkey'], $expected);
|
||||
$result = $ThePaper->findById(2);
|
||||
$expected = array(
|
||||
array(
|
||||
'id' => '2',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 2',
|
||||
'typ' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => '3',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 3',
|
||||
'typ' => '2'
|
||||
));
|
||||
$this->assertEqual($result['Monkey'], $expected);
|
||||
|
||||
$ThePaper = new ThePaper();
|
||||
$ThePaper->id = 2;
|
||||
$ThePaper->save(array('Monkey' => array(2, 3)));
|
||||
$ThePaper->delete(1);
|
||||
$result = $ThePaper->findById(2);
|
||||
$expected = array(
|
||||
array(
|
||||
'id' => '2',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 2',
|
||||
'typ' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => '3',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 3',
|
||||
'typ' => '2'
|
||||
));
|
||||
$this->assertEqual($result['Monkey'], $expected);
|
||||
}
|
||||
|
||||
$result = $ThePaper->findById(2);
|
||||
$expected = array(
|
||||
array(
|
||||
'id' => '2',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 2',
|
||||
'typ' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => '3',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 3',
|
||||
'typ' => '2'
|
||||
));
|
||||
$this->assertEqual($result['Monkey'], $expected);
|
||||
/**
|
||||
* test that beforeDelete returning false can abort deletion.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testBeforeDeleteDeleteAbortion() {
|
||||
$this->loadFixtures('Post');
|
||||
$Model = new CallbackPostTestModel();
|
||||
$Model->beforeDeleteReturn = false;
|
||||
|
||||
$ThePaper->delete(1);
|
||||
$result = $ThePaper->findById(2);
|
||||
$expected = array(
|
||||
array(
|
||||
'id' => '2',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 2',
|
||||
'typ' => '1'
|
||||
),
|
||||
array(
|
||||
'id' => '3',
|
||||
'device_type_id' => '1',
|
||||
'name' => 'Device 3',
|
||||
'typ' => '2'
|
||||
));
|
||||
$this->assertEqual($result['Monkey'], $expected);
|
||||
}
|
||||
$result = $Model->delete(1);
|
||||
$this->assertFalse($result);
|
||||
|
||||
/**
|
||||
* test that beforeDelete returning false can abort deletion.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testBeforeDeleteDeleteAbortion() {
|
||||
$this->loadFixtures('Post');
|
||||
$Model = new CallbackPostTestModel();
|
||||
$Model->beforeDeleteReturn = false;
|
||||
$exists = $Model->findById(1);
|
||||
$this->assertTrue(is_array($exists));
|
||||
}
|
||||
|
||||
$result = $Model->delete(1);
|
||||
$this->assertFalse($result);
|
||||
/**
|
||||
* test for a habtm deletion error that occurs in postgres but should not.
|
||||
* And should not occur in any dbo.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteHabtmPostgresFailure() {
|
||||
$this->loadFixtures('Article', 'Tag', 'ArticlesTag');
|
||||
|
||||
$exists = $Model->findById(1);
|
||||
$this->assertTrue(is_array($exists));
|
||||
}
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$Article->hasAndBelongsToMany['Tag']['unique'] = true;
|
||||
|
||||
/**
|
||||
* test for a habtm deletion error that occurs in postgres but should not.
|
||||
* And should not occur in any dbo.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testDeleteHabtmPostgresFailure() {
|
||||
$this->loadFixtures('Article', 'Tag', 'ArticlesTag');
|
||||
$Tag = ClassRegistry::init('Tag');
|
||||
$Tag->bindModel(array('hasAndBelongsToMany' => array(
|
||||
'Article' => array(
|
||||
'className' => 'Article',
|
||||
'unique' => true
|
||||
)
|
||||
)), true);
|
||||
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$Article->hasAndBelongsToMany['Tag']['unique'] = true;
|
||||
// Article 1 should have Tag.1 and Tag.2
|
||||
$before = $Article->find("all", array(
|
||||
"conditions" => array("Article.id" => 1),
|
||||
));
|
||||
$this->assertEqual(count($before[0]['Tag']), 2, 'Tag count for Article.id = 1 is incorrect, should be 2 %s');
|
||||
|
||||
$Tag = ClassRegistry::init('Tag');
|
||||
$Tag->bindModel(array('hasAndBelongsToMany' => array(
|
||||
'Article' => array(
|
||||
'className' => 'Article',
|
||||
'unique' => true
|
||||
)
|
||||
)), true);
|
||||
// From now on, Tag #1 is only associated with Post #1
|
||||
$submitted_data = array(
|
||||
"Tag" => array("id" => 1, 'tag' => 'tag1'),
|
||||
"Article" => array(
|
||||
"Article" => array(1)
|
||||
)
|
||||
);
|
||||
$Tag->save($submitted_data);
|
||||
|
||||
// Article 1 should have Tag.1 and Tag.2
|
||||
$before = $Article->find("all", array(
|
||||
"conditions" => array("Article.id" => 1),
|
||||
));
|
||||
$this->assertEqual(count($before[0]['Tag']), 2, 'Tag count for Article.id = 1 is incorrect, should be 2 %s');
|
||||
// One more submission (The other way around) to make sure the reverse save looks good.
|
||||
$submitted_data = array(
|
||||
"Article" => array("id" => 2, 'title' => 'second article'),
|
||||
"Tag" => array(
|
||||
"Tag" => array(2, 3)
|
||||
)
|
||||
);
|
||||
// ERROR:
|
||||
// Postgresql: DELETE FROM "articles_tags" WHERE tag_id IN ('1', '3')
|
||||
// MySQL: DELETE `ArticlesTag` FROM `articles_tags` AS `ArticlesTag` WHERE `ArticlesTag`.`article_id` = 2 AND `ArticlesTag`.`tag_id` IN (1, 3)
|
||||
$Article->save($submitted_data);
|
||||
|
||||
// From now on, Tag #1 is only associated with Post #1
|
||||
$submitted_data = array(
|
||||
"Tag" => array("id" => 1, 'tag' => 'tag1'),
|
||||
"Article" => array(
|
||||
"Article" => array(1)
|
||||
)
|
||||
);
|
||||
$Tag->save($submitted_data);
|
||||
// Want to make sure Article #1 has Tag #1 and Tag #2 still.
|
||||
$after = $Article->find("all", array(
|
||||
"conditions" => array("Article.id" => 1),
|
||||
));
|
||||
|
||||
// One more submission (The other way around) to make sure the reverse save looks good.
|
||||
$submitted_data = array(
|
||||
"Article" => array("id" => 2, 'title' => 'second article'),
|
||||
"Tag" => array(
|
||||
"Tag" => array(2, 3)
|
||||
)
|
||||
);
|
||||
// ERROR:
|
||||
// Postgresql: DELETE FROM "articles_tags" WHERE tag_id IN ('1', '3')
|
||||
// MySQL: DELETE `ArticlesTag` FROM `articles_tags` AS `ArticlesTag` WHERE `ArticlesTag`.`article_id` = 2 AND `ArticlesTag`.`tag_id` IN (1, 3)
|
||||
$Article->save($submitted_data);
|
||||
// Removing Article #2 from Tag #1 is all that should have happened.
|
||||
$this->assertEqual(count($before[0]["Tag"]), count($after[0]["Tag"]));
|
||||
}
|
||||
|
||||
// Want to make sure Article #1 has Tag #1 and Tag #2 still.
|
||||
$after = $Article->find("all", array(
|
||||
"conditions" => array("Article.id" => 1),
|
||||
));
|
||||
/**
|
||||
* test that deleting records inside the beforeDelete doesn't truncate the table.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testBeforeDeleteWipingTable() {
|
||||
$this->loadFixtures('Comment');
|
||||
|
||||
// Removing Article #2 from Tag #1 is all that should have happened.
|
||||
$this->assertEqual(count($before[0]["Tag"]), count($after[0]["Tag"]));
|
||||
}
|
||||
$Comment =& new BeforeDeleteComment();
|
||||
// Delete 3 records.
|
||||
$Comment->delete(4);
|
||||
$result = $Comment->find('count');
|
||||
|
||||
$this->assertTrue($result > 1, 'Comments are all gone.');
|
||||
$Comment->create(array(
|
||||
'article_id' => 1,
|
||||
'user_id' => 2,
|
||||
'comment' => 'new record',
|
||||
'published' => 'Y'
|
||||
));
|
||||
$Comment->save();
|
||||
|
||||
$Comment->delete(5);
|
||||
$result = $Comment->find('count');
|
||||
|
||||
$this->assertTrue($result > 1, 'Comments are all gone.');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that deleting the same record from the beforeDelete and the delete doesn't truncate the table.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testBeforeDeleteWipingTableWithDuplicateDelete() {
|
||||
$this->loadFixtures('Comment');
|
||||
|
||||
$Comment =& new BeforeDeleteComment();
|
||||
$Comment->delete(1);
|
||||
|
||||
$result = $Comment->find('count');
|
||||
$this->assertTrue($result > 1, 'Comments are all gone.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -631,7 +631,7 @@ class ModelValidationTest extends BaseModelTest {
|
|||
|
||||
$Something->create();
|
||||
$result = $Something->saveAll($data, array('validate' => 'first'));
|
||||
$this->assertEquals($result, array());
|
||||
$this->assertFalse($result);
|
||||
$this->assertEqual($JoinThing->validationErrors, $expectedError);
|
||||
|
||||
$count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id'])));
|
||||
|
|
|
@ -2737,7 +2737,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'Attachment' => array('attachment' => '')
|
||||
),
|
||||
array('validate' => 'first')
|
||||
), array());
|
||||
), false);
|
||||
$expected = array(
|
||||
'Comment' => array('comment' => 'This field cannot be left blank'),
|
||||
'Attachment' => array('attachment' => 'This field cannot be left blank')
|
||||
|
@ -2954,7 +2954,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function testSaveAllTransactionNoRollback() {
|
||||
function testSaveAllManyRowsTransactionNoRollback() {
|
||||
$this->loadFixtures('Post');
|
||||
|
||||
$this->getMock('DboSource', array(), array(), 'MockTransactionDboSource');
|
||||
|
@ -2984,6 +2984,54 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$Post->saveAll($data, array('atomic' => true));
|
||||
}
|
||||
|
||||
/**
|
||||
* test saveAll with transactions and ensure there is no missing rollback.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testSaveAllAssociatedTransactionNoRollback() {
|
||||
$testDb = ConnectionManager::getDataSource('test');
|
||||
|
||||
$mock = $this->getMock('DboSource', array(), array(), 'MockTransactionAssociatedDboSource', false);
|
||||
$db =& ConnectionManager::create('mock_transaction_assoc', array(
|
||||
'datasource' => 'MockTransactionAssociatedDbo',
|
||||
));
|
||||
$this->mockObjects[] = $db;
|
||||
$db->columns = $testDb->columns;
|
||||
|
||||
$db->expects($this->once())->method('rollback');
|
||||
$db->expects($this->any())->method('isInterfaceSupported')
|
||||
->will($this->returnValue(true));
|
||||
$db->expects($this->any())->method('describe')
|
||||
->will($this->returnValue(array(
|
||||
'id' => array('type' => 'integer'),
|
||||
'title' => array('type' => 'string'),
|
||||
'body' => array('type' => 'text'),
|
||||
'published' => array('type' => 'string')
|
||||
)));
|
||||
|
||||
$Post =& new Post();
|
||||
$Post->useDbConfig = 'mock_transaction_assoc';
|
||||
$Post->Author->useDbConfig = 'mock_transaction_assoc';
|
||||
|
||||
$Post->Author->validate = array(
|
||||
'user' => array('rule' => array('notEmpty'))
|
||||
);
|
||||
|
||||
$data = array(
|
||||
'Post' => array(
|
||||
'title' => 'New post',
|
||||
'body' => 'Content',
|
||||
'published' => 'Y'
|
||||
),
|
||||
'Author' => array(
|
||||
'user' => '',
|
||||
'password' => "sekret"
|
||||
)
|
||||
);
|
||||
$Post->saveAll($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveAllTransaction method
|
||||
*
|
||||
|
@ -3451,7 +3499,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
)
|
||||
), array('validate' => 'first'));
|
||||
|
||||
$this->assertEquals($result, array());
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $model->find('all');
|
||||
$this->assertEqual($result, array());
|
||||
|
|
|
@ -284,6 +284,24 @@ class Article extends CakeTestModel {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Model stub for beforeDelete testing
|
||||
*
|
||||
* @see #250
|
||||
* @package cake.tests
|
||||
*/
|
||||
class BeforeDeleteComment extends CakeTestModel {
|
||||
var $name = 'BeforeDeleteComment';
|
||||
|
||||
var $useTable = 'comments';
|
||||
|
||||
function beforeDelete($cascade = true) {
|
||||
$db =& $this->getDataSource();
|
||||
$db->delete($this, array($this->alias . '.' . $this->primaryKey => array(1, 3)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NumericArticle class
|
||||
*
|
||||
|
|
|
@ -236,6 +236,16 @@ class SanitizeTest extends CakeTestCase {
|
|||
$expected = 'The "lazy" dog 'jumped' & flew over the moon. If (1+1) = 2 <em>is</em> true, (2-1) = 1 is also true';
|
||||
$result = Sanitize::html($string);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$string = 'The "lazy" dog & his friend Apple® conquered the world';
|
||||
$expected = 'The "lazy" dog & his friend Apple&reg; conquered the world';
|
||||
$result = Sanitize::html($string);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$string = 'The "lazy" dog & his friend Apple® conquered the world';
|
||||
$expected = 'The "lazy" dog & his friend Apple® conquered the world';
|
||||
$result = Sanitize::html($string, array('double' => false));
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -855,6 +855,39 @@ class SetTest extends CakeTestCase {
|
|||
$r = Set::extract('/file/.[type=application/zip]', $f);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$f = array(
|
||||
array(
|
||||
'file' => array(
|
||||
'name' => 'zipfile.zip',
|
||||
'type' => 'application/zip',
|
||||
'tmp_name' => '/tmp/php178.tmp',
|
||||
'error' => 0,
|
||||
'size' => '564647'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'file' => array(
|
||||
'name' => 'zipfile2.zip',
|
||||
'type' => 'application/x zip compressed',
|
||||
'tmp_name' => '/tmp/php179.tmp',
|
||||
'error' => 0,
|
||||
'size' => '354784'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'file' => array(
|
||||
'name' => 'picture.jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'tmp_name' => '/tmp/php180.tmp',
|
||||
'error' => 0,
|
||||
'size' => '21324'
|
||||
)
|
||||
)
|
||||
);
|
||||
$expected = array(array('name' => 'zipfile2.zip','type' => 'application/x zip compressed','tmp_name' => '/tmp/php179.tmp','error' => 0,'size' => '354784'));
|
||||
$r = Set::extract('/file/.[type=application/x zip compressed]', $f);
|
||||
$this->assertEqual($r, $expected);
|
||||
|
||||
$hasMany = array(
|
||||
'Node' => array(
|
||||
'id' => 1,
|
||||
|
@ -1132,6 +1165,27 @@ class SetTest extends CakeTestCase {
|
|||
$expected = array(0 => array('Article' => array('id' => 1, 'approved' => 1)));
|
||||
$result = Set::extract('/Article[approved=1]', $startingAtOne);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$items = array(
|
||||
240 => array(
|
||||
'A' => array(
|
||||
'field1' => 'a240',
|
||||
'field2' => 'a240',
|
||||
),
|
||||
'B' => array(
|
||||
'field1' => 'b240',
|
||||
'field2' => 'b240'
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$expected = array(
|
||||
0 => 'b240'
|
||||
);
|
||||
|
||||
$result = Set::extract('/B/field1', $items);
|
||||
$this->assertIdentical($result, $expected);
|
||||
$this->assertIdentical($result, Set::extract('{n}.B.field1', $items));
|
||||
}
|
||||
/**
|
||||
* testExtractWithArrays method
|
||||
|
@ -2674,20 +2728,20 @@ class SetTest extends CakeTestCase {
|
|||
</item>
|
||||
</channel>
|
||||
</rss>';
|
||||
$xml = new Xml($string);
|
||||
$xml = Xml::build($string);
|
||||
$result = Set::reverse($xml);
|
||||
$expected = array('Rss' => array(
|
||||
$expected = array('rss' => array(
|
||||
'version' => '2.0',
|
||||
'Channel' => array(
|
||||
'channel' => array(
|
||||
'title' => 'Cake PHP Google Group',
|
||||
'link' => 'http://groups.google.com/group/cake-php',
|
||||
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
|
||||
'language' => 'en',
|
||||
'Item' => array(
|
||||
'item' => array(
|
||||
array(
|
||||
'title' => 'constructng result array when using findall',
|
||||
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
||||
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
|
||||
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] => Array(",
|
||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
||||
'author' => 'bmil...@gmail.com(bpscrugs)',
|
||||
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
||||
|
@ -2706,43 +2760,43 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
$string ='<data><post title="Title of this post" description="cool"/></data>';
|
||||
|
||||
$xml = new Xml($string);
|
||||
$xml = Xml::build($string);
|
||||
$result = Set::reverse($xml);
|
||||
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
|
||||
$expected = array('data' => array('post' => array('title' => 'Title of this post', 'description' => 'cool')));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$xml = new Xml('<example><item><title>An example of a correctly reversed XMLNode</title><desc/></item></example>');
|
||||
$xml = Xml::build('<example><item><title>An example of a correctly reversed SimpleXMLElement</title><desc/></item></example>');
|
||||
$result = Set::reverse($xml);
|
||||
$expected = array('Example' =>
|
||||
$expected = array('example' =>
|
||||
array(
|
||||
'Item' => array(
|
||||
'title' => 'An example of a correctly reversed XMLNode',
|
||||
'desc' => array(),
|
||||
'item' => array(
|
||||
'title' => 'An example of a correctly reversed SimpleXMLElement',
|
||||
'desc' => '',
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->assertEquals($result, $expected);
|
||||
|
||||
$xml = new Xml('<example><item attr="123"><titles><title>title1</title><title>title2</title></titles></item></example>');
|
||||
$xml = Xml::build('<example><item attr="123"><titles><title>title1</title><title>title2</title></titles></item></example>');
|
||||
$result = Set::reverse($xml);
|
||||
$expected =
|
||||
array('Example' => array(
|
||||
'Item' => array(
|
||||
array('example' => array(
|
||||
'item' => array(
|
||||
'attr' => '123',
|
||||
'Titles' => array(
|
||||
'Title' => array('title1', 'title2')
|
||||
'titles' => array(
|
||||
'title' => array('title1', 'title2')
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->assertEquals($result, $expected);
|
||||
|
||||
$xml = new Xml('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
|
||||
$xml = Xml::build('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
|
||||
$result = Set::reverse($xml);
|
||||
$expected =
|
||||
array('Example' => array(
|
||||
array('example' => array(
|
||||
'attr' => 'ex_attr',
|
||||
'Item' => array(
|
||||
'item' => array(
|
||||
'attr' => '123',
|
||||
'titles' => 'list',
|
||||
'value' => 'textforitems'
|
||||
|
@ -2752,7 +2806,7 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertEquals($result, $expected);
|
||||
|
||||
$string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<rss version="2.0">
|
||||
<rss version="2.0" xmlns:dc="http://www.cakephp.org/">
|
||||
<channel>
|
||||
<title>Cake PHP Google Group</title>
|
||||
<link>http://groups.google.com/group/cake-php</link>
|
||||
|
@ -2783,23 +2837,23 @@ class SetTest extends CakeTestCase {
|
|||
</channel>
|
||||
</rss>';
|
||||
|
||||
$xml = new Xml($string);
|
||||
$xml = Xml::build($string);
|
||||
$result = Set::reverse($xml);
|
||||
|
||||
$expected = array('Rss' => array(
|
||||
$expected = array('rss' => array(
|
||||
'version' => '2.0',
|
||||
'Channel' => array(
|
||||
'channel' => array(
|
||||
'title' => 'Cake PHP Google Group',
|
||||
'link' => 'http://groups.google.com/group/cake-php',
|
||||
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
|
||||
'language' => 'en',
|
||||
'Item' => array(
|
||||
'item' => array(
|
||||
array(
|
||||
'title' => 'constructng result array when using findall',
|
||||
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
||||
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br><p>Array( <br> [0] => Array(",
|
||||
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] => Array(",
|
||||
'creator' => 'cakephp',
|
||||
'Category' => array('cakephp', 'model'),
|
||||
'category' => array('cakephp', 'model'),
|
||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
||||
'author' => 'bmil...@gmail.com(bpscrugs)',
|
||||
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
||||
|
@ -2809,7 +2863,7 @@ class SetTest extends CakeTestCase {
|
|||
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
||||
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
||||
'creator' => 'cakephp',
|
||||
'Category' => array('cakephp', 'model'),
|
||||
'category' => array('cakephp', 'model'),
|
||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
||||
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
||||
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
||||
|
@ -2841,15 +2895,13 @@ class SetTest extends CakeTestCase {
|
|||
</XRD>
|
||||
</XRDS>';
|
||||
|
||||
$xml = new Xml($text);
|
||||
$xml = Xml::build($text);
|
||||
$result = Set::reverse($xml);
|
||||
|
||||
$expected = array('XRDS' => array(
|
||||
'xmlns' => 'xri://$xrds',
|
||||
'XRD' => array(
|
||||
array(
|
||||
'xml:id' => 'oauth',
|
||||
'xmlns' => 'xri://$XRD*($v*2.0)',
|
||||
'id' => 'oauth',
|
||||
'version' => '2.0',
|
||||
'Type' => 'xri://$xrds*simple',
|
||||
'Expires' => '2008-04-13T07:34:58Z',
|
||||
|
@ -2872,7 +2924,6 @@ class SetTest extends CakeTestCase {
|
|||
)
|
||||
),
|
||||
array(
|
||||
'xmlns' => 'xri://$XRD*($v*2.0)',
|
||||
'version' => '2.0',
|
||||
'Type' => 'xri://$xrds*simple',
|
||||
'Service' => array(
|
||||
|
|
|
@ -595,6 +595,13 @@ class HelperTest extends CakeTestCase {
|
|||
$this->assertEqual($this->View->association, null);
|
||||
$this->assertEqual($this->View->fieldSuffix, null);
|
||||
|
||||
$this->Helper->setEntity('HelperTestTag');
|
||||
$this->assertEqual($this->View->model, 'HelperTestTag');
|
||||
$this->assertEqual($this->View->field, 'HelperTestTag');
|
||||
$this->assertEqual($this->View->modelId, null);
|
||||
$this->assertEqual($this->View->association, null);
|
||||
$this->assertEqual($this->View->fieldSuffix, null);
|
||||
$this->assertEqual($this->View->entityPath, 'HelperTestTag');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1871,7 +1871,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
|
||||
$result = $this->Form->input('User.active', array('label' => false, 'checked' => '1'));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input checkbox'),
|
||||
|
@ -2249,6 +2249,33 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertPattern('/input type="radio"/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* fields with the same name as the model should work.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testInputWithMatchingFieldAndModelName() {
|
||||
$this->Form->create('User');
|
||||
$this->Form->fieldset = array(
|
||||
'User' => array(
|
||||
'fields' => array(
|
||||
'User' => array('type' => 'text')
|
||||
),
|
||||
'validates' => array(),
|
||||
'key' => 'id'
|
||||
)
|
||||
);
|
||||
$this->Form->request->data['User']['User'] = 'ABC, Inc.';
|
||||
$result = $this->Form->input('User', array('type' => 'text'));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
'label' => array('for' => 'UserUser'), 'User', '/label',
|
||||
'input' => array('name' => 'data[User][User]', 'type' => 'text', 'id' => 'UserUser', 'value' => 'ABC, Inc.'),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testFormInputs method
|
||||
*
|
||||
|
@ -2475,6 +2502,18 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->select('Model.multi_field', array('1/2' => 'half'), null, array('multiple' => 'checkbox'));
|
||||
$expected = array(
|
||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'),
|
||||
array('div' => array('class' => 'checkbox')),
|
||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][multi_field][]', 'value' => '1/2', 'id' => 'ModelMultiField12')),
|
||||
array('label' => array('for' => 'ModelMultiField12')),
|
||||
'half',
|
||||
'/label',
|
||||
'/div',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2664,6 +2703,16 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->radio('Model.field', array('1/2' => 'half'));
|
||||
$expected = array(
|
||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '', 'id' => 'ModelField_'),
|
||||
array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '1/2', 'id' => 'ModelField12')),
|
||||
'label' => array('for' => 'ModelField12'),
|
||||
'half',
|
||||
'/label'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->radio('Model.field', array('option A', 'option B'));
|
||||
$expected = array(
|
||||
'fieldset' => array(),
|
||||
|
@ -3066,6 +3115,47 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that select() with optiongroups listens to the escape param.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testSelectOptionGroupEscaping() {
|
||||
$options = array(
|
||||
'>< Key' => array(
|
||||
1 => 'One',
|
||||
2 => 'Two'
|
||||
)
|
||||
);
|
||||
$result = $this->Form->select('Model.field', $options, null, array('empty' => false));
|
||||
$expected = array(
|
||||
'select' => array('name' => 'data[Model][field]', 'id' => 'ModelField'),
|
||||
'optgroup' => array('label' => '>< Key'),
|
||||
array('option' => array('value' => '1')), 'One', '/option',
|
||||
array('option' => array('value' => '2')), 'Two', '/option',
|
||||
'/optgroup',
|
||||
'/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$options = array(
|
||||
'>< Key' => array(
|
||||
1 => 'One',
|
||||
2 => 'Two'
|
||||
)
|
||||
);
|
||||
$result = $this->Form->select('Model.field', $options, null, array('empty' => false, 'escape' => false));
|
||||
$expected = array(
|
||||
'select' => array('name' => 'data[Model][field]', 'id' => 'ModelField'),
|
||||
'optgroup' => array('label' => '>< Key'),
|
||||
array('option' => array('value' => '1')), 'One', '/option',
|
||||
array('option' => array('value' => '2')), 'Two', '/option',
|
||||
'/optgroup',
|
||||
'/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that FormHelper::select() allows null to be passed in the $attributes parameter
|
||||
*
|
||||
|
@ -3448,7 +3538,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function testInputMultipleCheckboxes() {
|
||||
$result = $this->Form->input('Model.multi_field', array(
|
||||
'options' => array('first', 'second', 'third'),
|
||||
'options' => array('first', 'second', 'third'),
|
||||
'multiple' => 'checkbox'
|
||||
));
|
||||
$expected = array(
|
||||
|
@ -3531,7 +3621,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$result = $this->Form->input('Model.multi_field', array(
|
||||
'options' => array('2' => 'second'),
|
||||
'multiple' => 'checkbox',
|
||||
'label' => false,
|
||||
'label' => false,
|
||||
'div' => false
|
||||
));
|
||||
$expected = array(
|
||||
|
@ -5484,6 +5574,36 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that create() doesn't add in extra passed params.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testCreatePassedArgs() {
|
||||
$encoding = strtolower(Configure::read('App.encoding'));
|
||||
$this->Form->request->data['Contact']['id'] = 1;
|
||||
$result = $this->Form->create('Contact', array(
|
||||
'type' => 'post',
|
||||
'escape' => false,
|
||||
'url' => array(
|
||||
'action' => 'edit',
|
||||
'myparam'
|
||||
)
|
||||
));
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm',
|
||||
'method' => 'post',
|
||||
'action' => '/contacts/edit/myparam',
|
||||
'accept-charset' => $encoding
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* test creating a get form, and get form inputs.
|
||||
*
|
||||
|
|
|
@ -189,7 +189,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
|
|||
'method' => 'post',
|
||||
'wrapCallbacks' => false
|
||||
));
|
||||
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$expected = '$.ajax({dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Jquery->request('/people/edit/1', array(
|
||||
|
@ -200,7 +200,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
|
|||
'data' => '$("#someId").serialize()',
|
||||
'wrapCallbacks' => false
|
||||
));
|
||||
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$expected = '$.ajax({data:$("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Jquery->request('/people/edit/1', array(
|
||||
|
@ -230,7 +230,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
|
|||
'data' => '$j("#someId").serialize()',
|
||||
'wrapCallbacks' => false
|
||||
));
|
||||
$expected = '$j.ajax({data:$j("#someId").serialize(), dataType:"html", success:function (data, textStatus) {$j("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$expected = '$j.ajax({data:$j("#someId").serialize(), dataType:"html", success:function (data, textStatus) {doFoo$j("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ class RssHelperTest extends CakeTestCase {
|
|||
$controller = null;
|
||||
$this->View = new View($controller);
|
||||
$this->Rss = new RssHelper($this->View);
|
||||
|
||||
$manager =& XmlManager::getInstance();
|
||||
$manager->namespaces = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,52 +51,6 @@ class RssHelperTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* testAddNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testAddNamespace() {
|
||||
$this->Rss->addNs('custom', 'http://example.com/dtd.xml');
|
||||
$manager =& XmlManager::getInstance();
|
||||
|
||||
$expected = array('custom' => 'http://example.com/dtd.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
|
||||
$this->Rss->removeNs('custom');
|
||||
|
||||
$this->Rss->addNs('dummy', 'http://dummy.com/1.0/');
|
||||
$result = $this->Rss->document();
|
||||
$expected = array(
|
||||
'rss' => array(
|
||||
'xmlns:dummy' => 'http://dummy.com/1.0/',
|
||||
'version' => '2.0'
|
||||
)
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Rss->removeNs('dummy');
|
||||
}
|
||||
|
||||
/**
|
||||
* testRemoveNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRemoveNamespace() {
|
||||
$this->Rss->addNs('custom', 'http://example.com/dtd.xml');
|
||||
$this->Rss->addNs('custom2', 'http://example.com/dtd2.xml');
|
||||
$manager =& XmlManager::getInstance();
|
||||
|
||||
$expected = array('custom' => 'http://example.com/dtd.xml', 'custom2' => 'http://example.com/dtd2.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
|
||||
$this->Rss->removeNs('custom');
|
||||
$expected = array('custom2' => 'http://example.com/dtd2.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
}
|
||||
/**
|
||||
* testDocument method
|
||||
*
|
||||
* @access public
|
||||
|
@ -253,6 +204,7 @@ class RssHelperTest extends CakeTestCase {
|
|||
'<link', 'http://example.com', '/link',
|
||||
'/image',
|
||||
'atom:link' => array(
|
||||
'xmlns:atom' => 'http://www.w3.org/2005/Atom',
|
||||
'href' => "http://www.example.com/rss.xml",
|
||||
'rel' => "self",
|
||||
'type' =>"application/rss+xml"
|
||||
|
@ -387,22 +339,6 @@ class RssHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$item = array(
|
||||
'title' => array(
|
||||
'value' => 'My Title & more',
|
||||
'convertEntities' => false
|
||||
)
|
||||
);
|
||||
$result = $this->Rss->item(null, $item);
|
||||
$expected = array(
|
||||
'<item',
|
||||
'<title',
|
||||
'My Title & more',
|
||||
'/title',
|
||||
'/item'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$item = array(
|
||||
'title' => array(
|
||||
'value' => 'My Title & more',
|
||||
|
|
|
@ -1,289 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* XmlHelperTest file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
App::import('Helper', 'Xml');
|
||||
App::import('Core', 'View');
|
||||
|
||||
/**
|
||||
* TestXml class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
*/
|
||||
class TestXmlHelper extends Object {
|
||||
|
||||
/**
|
||||
* content property
|
||||
*
|
||||
* @var string ''
|
||||
* @access public
|
||||
*/
|
||||
public $content = '';
|
||||
|
||||
/**
|
||||
* construct method
|
||||
*
|
||||
* @param mixed $content
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __construct($content) {
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* toString method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function toString() {
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* XmlHelperTest class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.view.helpers
|
||||
*/
|
||||
class XmlHelperTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
$controller = null;
|
||||
$View = new View($controller);
|
||||
$this->Xml = new XmlHelper($View);
|
||||
$manager =& XmlManager::getInstance();
|
||||
$manager->namespaces = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
unset($this->Xml);
|
||||
}
|
||||
|
||||
/**
|
||||
* testAddNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testAddNamespace() {
|
||||
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
||||
$manager =& XmlManager::getInstance();
|
||||
|
||||
$expected = array('custom' => 'http://example.com/dtd.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testRemoveNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRemoveNamespace() {
|
||||
$this->Xml->addNs('custom', 'http://example.com/dtd.xml');
|
||||
$this->Xml->addNs('custom2', 'http://example.com/dtd2.xml');
|
||||
$manager =& XmlManager::getInstance();
|
||||
|
||||
$expected = array('custom' => 'http://example.com/dtd.xml', 'custom2' => 'http://example.com/dtd2.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
|
||||
$this->Xml->removeNs('custom');
|
||||
$expected = array('custom2' => 'http://example.com/dtd2.xml');
|
||||
$this->assertEqual($manager->namespaces, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testRenderZeroElement method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRenderZeroElement() {
|
||||
$result = $this->Xml->elem('count', null, 0);
|
||||
$expected = '<count>0</count>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Xml->elem('count', null, array('cdata' => true, 'value' => null));
|
||||
$expected = '<count />';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testRenderElementWithNamespace method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRenderElementWithNamespace() {
|
||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content');
|
||||
$expected = '<myNameSpace:count>content</myNameSpace:count>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content', false);
|
||||
$expected = '<myNameSpace:count>content';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected .= '</myNameSpace:count>';
|
||||
$result .= $this->Xml->closeElem();
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testRenderElementWithComplexContent method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testRenderElementWithComplexContent() {
|
||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), array('contrived' => 'content'));
|
||||
$expected = '<myNameSpace:count><content /></myNameSpace:count>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), array('cdata' => true, 'value' => 'content'));
|
||||
$expected = '<myNameSpace:count><![CDATA[content]]></myNameSpace:count>';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSerialize method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSerialize() {
|
||||
$data = array(
|
||||
'test1' => 'test with no quotes',
|
||||
'test2' => 'test with "double quotes"'
|
||||
);
|
||||
$result = $this->Xml->serialize($data);
|
||||
$expected = '<std_class test1="test with no quotes" test2="test with "double quotes"" />';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$data = array(
|
||||
'test1' => 'test with no quotes',
|
||||
'test2' => 'test without double quotes'
|
||||
);
|
||||
$result = $this->Xml->serialize($data);
|
||||
$expected = '<std_class test1="test with no quotes" test2="test without double quotes" />';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$data = array(
|
||||
'ServiceDay' => array('ServiceTime' => array('ServiceTimePrice' => array('dollar' => 1, 'cents' => '2')))
|
||||
);
|
||||
$result = $this->Xml->serialize($data);
|
||||
$expected = '<service_day><service_time><service_time_price dollar="1" cents="2" /></service_time></service_day>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$data = array(
|
||||
'ServiceDay' => array('ServiceTime' => array('ServiceTimePrice' => array('dollar' => 1, 'cents' => '2')))
|
||||
);
|
||||
$result = $this->Xml->serialize($data, array('format' => 'tags'));
|
||||
$expected = '<service_day><service_time><service_time_price><dollar>1</dollar><cents>2</cents></service_time_price></service_time></service_day>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$data = array(
|
||||
'Pages' => array('id' => 2, 'url' => 'http://www.url.com/rb/153/?id=bbbb&t=access')
|
||||
);
|
||||
$result = $this->Xml->serialize($data);
|
||||
$expected = '<pages id="2" url="http://www.url.com/rb/153/?id=bbbb&t=access" />';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$test = array(
|
||||
'Test' => array('test' => true)
|
||||
);
|
||||
$expected = '<test test="1" />';
|
||||
$result = $this->Xml->serialize($test);
|
||||
$this->assertidentical($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSerializeOnMultiDimensionalArray method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSerializeOnMultiDimensionalArray() {
|
||||
$data = array(
|
||||
'Statuses' => array(
|
||||
array('Status' => array('id' => 1)),
|
||||
array('Status' => array('id' => 2))
|
||||
)
|
||||
);
|
||||
$result = $this->Xml->serialize($data, array('format' => 'tags'));
|
||||
$expected = '<statuses><status><id>1</id></status><status><id>2</id></status></statuses>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* testHeader method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testHeader() {
|
||||
$expectedDefaultEncoding = Configure::read('App.encoding');
|
||||
if (empty($expectedDefaultEncoding)) {
|
||||
$expectedDefaultEncoding = 'UTF-8';
|
||||
}
|
||||
$attrib = array();
|
||||
$result = $this->Xml->header($attrib);
|
||||
$expected = '<?xml version="1.0" encoding="'.$expectedDefaultEncoding.'" ?>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$attrib = array(
|
||||
'encoding' => 'UTF-8',
|
||||
'version' => '1.1'
|
||||
);
|
||||
$result = $this->Xml->header($attrib);
|
||||
$expected = '<?xml version="1.1" encoding="UTF-8" ?>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$attrib = array(
|
||||
'encoding' => 'UTF-8',
|
||||
'version' => '1.2',
|
||||
'additional' => 'attribute'
|
||||
);
|
||||
$result = $this->Xml->header($attrib);
|
||||
$expected = '<?xml version="1.2" encoding="UTF-8" additional="attribute" ?>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
|
||||
$attrib = 'encoding="UTF-8" someOther="value"';
|
||||
$result = $this->Xml->header($attrib);
|
||||
$expected = '<?xml encoding="UTF-8" someOther="value" ?>';
|
||||
$this->assertIdentical($result, $expected);
|
||||
}
|
||||
}
|
|
@ -799,6 +799,75 @@ class ViewTest extends CakeTestCase {
|
|||
@unlink($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that render() will remove the cake:nocache tags when only the cachehelper is present.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testRenderStrippingNoCacheTagsOnlyCacheHelper() {
|
||||
Configure::write('Cache.check', false);
|
||||
$View =& new View($this->PostsController);
|
||||
$View->set(array('superman' => 'clark', 'variable' => 'var'));
|
||||
$View->helpers = array('Html', 'Form', 'Cache');
|
||||
$View->layout = 'cache_layout';
|
||||
$result = $View->render('index');
|
||||
$this->assertNoPattern('/cake:nocache/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that render() will remove the cake:nocache tags when only the Cache.check is true.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testRenderStrippingNoCacheTagsOnlyCacheCheck() {
|
||||
Configure::write('Cache.check', true);
|
||||
$View =& new View($this->PostsController);
|
||||
$View->set(array('superman' => 'clark', 'variable' => 'var'));
|
||||
$View->helpers = array('Html', 'Form');
|
||||
$View->layout = 'cache_layout';
|
||||
$result = $View->render('index');
|
||||
$this->assertNoPattern('/cake:nocache/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testRenderNocache method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
|
||||
/* This is a new test case for a pending enhancement
|
||||
function testRenderNocache() {
|
||||
$this->PostsController->helpers = array('Cache', 'Html');
|
||||
$this->PostsController->constructClasses();
|
||||
$this->PostsController->cacheAction = 21600;
|
||||
$this->PostsController->here = '/posts/nocache_multiple_element';
|
||||
$this->PostsController->action = 'nocache_multiple_element';
|
||||
$this->PostsController->nocache_multiple_element();
|
||||
Configure::write('Cache.check', true);
|
||||
Configure::write('Cache.disable', false);
|
||||
|
||||
$filename = CACHE . 'views' . DS . 'posts_nocache_multiple_element.php';
|
||||
|
||||
$View = new TestView($this->PostsController);
|
||||
$View->render();
|
||||
|
||||
ob_start();
|
||||
$View->renderCache($filename, getMicroTime());
|
||||
$result = ob_get_clean();
|
||||
@unlink($filename);
|
||||
|
||||
$this->assertPattern('/php echo \$foo;/', $result);
|
||||
$this->assertPattern('/php echo \$bar;/', $result);
|
||||
$this->assertPattern('/php \$barfoo = \'in sub2\';/', $result);
|
||||
$this->assertPattern('/php echo \$barfoo;/', $result);
|
||||
$this->assertPattern('/printing: "in sub2"/', $result);
|
||||
$this->assertPattern('/php \$foobar = \'in sub1\';/', $result);
|
||||
$this->assertPattern('/php echo \$foobar;/', $result);
|
||||
$this->assertPattern('/printing: "in sub1"/', $result);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* testSet method
|
||||
*
|
||||
|
@ -854,6 +923,15 @@ class ViewTest extends CakeTestCase {
|
|||
$View->entityPath = '0.Node.title';
|
||||
$expected = array(0, 'Node', 'title');
|
||||
$this->assertEqual($View->entity(), $expected);
|
||||
|
||||
$View->model = 'HelperTestTag';
|
||||
$View->field = 'HelperTestTag';
|
||||
$View->modelId = null;
|
||||
$View->association = null;
|
||||
$View->fieldSuffix = null;
|
||||
$View->entityPath = 'HelperTestTag';
|
||||
$expected = array('HelperTestTag', 'HelperTestTag');
|
||||
$this->assertEqual($View->entity(), $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load diff
33
cake/tests/fixtures/rss.xml
vendored
Normal file
33
cake/tests/fixtures/rss.xml
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<atom:link href="http://bakery.cakephp.org/articles/rss" rel="self" type="application/rss+xml" />
|
||||
<title>The Bakery: </title>
|
||||
<link>http://bakery.cakephp.org/</link>
|
||||
<description>Recent Articles at The Bakery.</description>
|
||||
<language>en-us</language>
|
||||
<pubDate>Wed, 01 Sep 2010 12:09:25 -0500</pubDate>
|
||||
<docs>http://validator.w3.org/feed/docs/rss2.html</docs>
|
||||
<generator>CakePHP Bakery</generator>
|
||||
<managingEditor>mariano@cricava.com (Mariano Iglesias)</managingEditor>
|
||||
<webMaster>gwoo@cakephp.org (Garrett Woodworth)</webMaster>
|
||||
<item>
|
||||
<title>EpisodeCMS</title>
|
||||
<link>http://bakery.cakephp.org/articles/view/episodecms</link>
|
||||
<description>EpisodeCMS is CakePHP based content management system.
|
||||
Features: control panel, events API, module management, multilanguage and translations, themes
|
||||
http://episodecms.com/
|
||||
|
||||
Please help me to improve it. Thanks.</description>
|
||||
<pubDate>Tue, 31 Aug 2010 02:07:02 -0500</pubDate>
|
||||
<guid>http://bakery.cakephp.org/articles/view/episodecms</guid>
|
||||
</item>
|
||||
<item>
|
||||
<title>Alertpay automated sales via IPN</title>
|
||||
<link>http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn</link>
|
||||
<description>I'm going to show you how I implemented a payment module via the Alertpay payment processor.</description>
|
||||
<pubDate>Tue, 31 Aug 2010 01:42:00 -0500</pubDate>
|
||||
<guid>http://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn</guid>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
9
cake/tests/fixtures/sample.xml
vendored
Normal file
9
cake/tests/fixtures/sample.xml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<tags>
|
||||
<tag id="1">
|
||||
<name>defect</name>
|
||||
</tag>
|
||||
<tag id="2">
|
||||
<name>enhancement</name>
|
||||
</tag>
|
||||
</tags>
|
12
cake/tests/fixtures/soap_request.xml
vendored
Normal file
12
cake/tests/fixtures/soap_request.xml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<soap:Envelope
|
||||
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
|
||||
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
|
||||
|
||||
<soap:Body xmlns:m="http://www.example.org/stock">
|
||||
<m:GetStockPrice>
|
||||
<m:StockName>IBM</m:StockName>
|
||||
</m:GetStockPrice>
|
||||
</soap:Body>
|
||||
|
||||
</soap:Envelope>
|
12
cake/tests/fixtures/soap_response.xml
vendored
Normal file
12
cake/tests/fixtures/soap_response.xml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0"?>
|
||||
<soap:Envelope
|
||||
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
|
||||
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
|
||||
|
||||
<soap:Body xmlns:m="http://www.example.org/stock">
|
||||
<m:GetStockPriceResponse>
|
||||
<m:Price>34.5</m:Price>
|
||||
</m:GetStockPriceResponse>
|
||||
</soap:Body>
|
||||
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
class TestPluginAppHelper extends AppHelper {
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue