Misc code formatting and whitespace fixes

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7020 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-05-23 05:11:41 +00:00
parent d3f772cfb4
commit 7402680cc1
21 changed files with 163 additions and 133 deletions

View file

@ -51,19 +51,19 @@ class ErrorHandler extends Object {
*/ */
function __construct($method, $messages) { function __construct($method, $messages) {
App::import('Controller', 'App'); App::import('Controller', 'App');
App::import('Core', 'Sanitize');
$this->controller =& new AppController(); $this->controller =& new AppController();
$this->controller->_set(Router::getPaths()); $this->controller->_set(Router::getPaths());
$this->controller->params = Router::getParams(); $this->controller->params = Router::getParams();
$this->controller->constructClasses(); $this->controller->constructClasses();
$this->controller->cacheAction = false; $this->controller->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
$this->controller->viewPath = 'errors';
$allow = array('.', '/', '_', ' ', '-', '~'); $allow = array('.', '/', '_', ' ', '-', '~');
if (substr(PHP_OS,0,3) == "WIN") { if (substr(PHP_OS, 0, 3) == "WIN") {
$allow = array_merge($allow, array('\\', ':') ); $allow = array_merge($allow, array('\\', ':'));
} }
App::import('Core', 'Sanitize');
$messages = Sanitize::paranoid($messages, $allow); $messages = Sanitize::paranoid($messages, $allow);
if (!isset($messages[0])) { if (!isset($messages[0])) {
@ -81,6 +81,9 @@ class ErrorHandler extends Object {
if ($method == 'error') { if ($method == 'error') {
$this->dispatchMethod($method, $messages); $this->dispatchMethod($method, $messages);
$this->stop(); $this->stop();
} elseif (Configure::read() == 0 && (isset($code) && $code == 500)) {
$this->dispatchMethod('error500', $messages);
exit();
} elseif (Configure::read() == 0) { } elseif (Configure::read() == 0) {
$this->dispatchMethod('error404', $messages); $this->dispatchMethod('error404', $messages);
$this->stop(); $this->stop();
@ -97,10 +100,12 @@ class ErrorHandler extends Object {
*/ */
function error($params) { function error($params) {
extract($params, EXTR_OVERWRITE); extract($params, EXTR_OVERWRITE);
$this->controller->set(array('code' => $code, $this->controller->set(array(
'name' => $name, 'code' => $code,
'message' => $message, 'name' => $name,
'title' => $code . ' ' . $name)); 'message' => $message,
'title' => $code . ' ' . $name
));
$this->__outputMessage('error404'); $this->__outputMessage('error404');
} }
/** /**
@ -117,10 +122,12 @@ class ErrorHandler extends Object {
} }
$url = Router::normalize($url); $url = Router::normalize($url);
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
$this->controller->set(array('code' => '404', $this->controller->set(array(
'name' => __('Not Found', true), 'code' => '404',
'message' => sprintf(__("The requested address %s was not found on this server.", true), "<strong>'{$url}'</strong>"), 'name' => __('Not Found', true),
'base' => $this->controller->base)); 'message' => sprintf(__("The requested address %s was not found on this server.", true), "<strong>'{$url}'</strong>"),
'base' => $this->controller->base
));
$this->__outputMessage('error404'); $this->__outputMessage('error404');
} }
/** /**

View file

@ -213,8 +213,8 @@ class File extends Object {
$lineBreak = "\n"; $lineBreak = "\n";
if (substr(PHP_OS,0,3) == "WIN" || $forceWindows === true) { if (substr(PHP_OS,0,3) == "WIN" || $forceWindows === true) {
$lineBreak = "\r\n"; $lineBreak = "\r\n";
} }
return strtr($data, array("\r\n" => $lineBreak, "\n" => $lineBreak, "\r" => $lineBreak)); return strtr($data, array("\r\n" => $lineBreak, "\n" => $lineBreak, "\r" => $lineBreak));
} }
/** /**

View file

@ -217,7 +217,7 @@ class TranslateBehavior extends ModelBehavior {
} }
} }
return $results; return $results;
} }
/** /**
* Callback * Callback
*/ */

View file

@ -492,8 +492,12 @@ class TreeBehavior extends ModelBehavior {
return false; return false;
} }
} }
$previousNode = $model->find('first', array('conditions' => array($scope, $model->escapeField($right) => ($node[$left] - 1)), $previousNode = $model->find('first', array(
'fields' => array($model->primaryKey, $left, $right), 'recursive' => $recursive)); 'conditions' => array($scope, $model->escapeField($right) => ($node[$left] - 1)),
'fields' => array($model->primaryKey, $left, $right),
'recursive' => $recursive
));
if ($previousNode) { if ($previousNode) {
list($previousNode) = array_values($previousNode); list($previousNode) = array_values($previousNode);
} else { } else {
@ -540,8 +544,12 @@ class TreeBehavior extends ModelBehavior {
'fields' => array($model->primaryKey, $left, $right, $parent, 'fields' => array($model->primaryKey, $left, $right, $parent,
'actsAs' => '') 'actsAs' => '')
)))); ))));
$missingParents = $model->find('list', array('recursive' => 0, 'conditions' => $missingParents = $model->find('list', array(
array($scope, array('NOT' => array($model->escapeField($parent) => null), $model->VerifyParent->escapeField() => null)))); 'recursive' => 0,
'conditions' => array($scope, array(
'NOT' => array($model->escapeField($parent) => null), $model->VerifyParent->escapeField() => null
))
));
$model->unbindModel(array('belongsTo' => array('VerifyParent'))); $model->unbindModel(array('belongsTo' => array('VerifyParent')));
if ($missingParents) { if ($missingParents) {
if ($missingParentAction == 'return') { if ($missingParentAction == 'return') {
@ -632,9 +640,13 @@ class TreeBehavior extends ModelBehavior {
extract (array_merge($id, array('id' => null))); extract (array_merge($id, array('id' => null)));
} }
extract($this->settings[$model->alias]); extract($this->settings[$model->alias]);
list($node) = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $id),
'fields' => array($model->primaryKey, $left, $right, $parent), 'recursive' => $recursive)) list($node) = array_values($model->find('first', array(
); 'conditions' => array($scope, $model->escapeField() => $id),
'fields' => array($model->primaryKey, $left, $right, $parent),
'recursive' => $recursive
)));
if ($node[$right] == $node[$left] + 1) { if ($node[$right] == $node[$left] + 1) {
if ($delete) { if ($delete) {
$model->delete(); $model->delete();
@ -642,12 +654,15 @@ class TreeBehavior extends ModelBehavior {
return false; return false;
} }
} elseif ($node[$parent]) { } elseif ($node[$parent]) {
list($parentNode) = array_values($model->find('first', array('conditions' => array($scope, $model->escapeField() => $node[$parent]), list($parentNode) = array_values($model->find('first', array(
'fields' => array($model->primaryKey, $left, $right), 'recursive' => $recursive)) 'conditions' => array($scope, $model->escapeField() => $node[$parent]),
); 'fields' => array($model->primaryKey, $left, $right),
'recursive' => $recursive
)));
} else { } else {
$parentNode[$right]= $node[$right] + 1; $parentNode[$right] = $node[$right] + 1;
} }
$model->updateAll(array($parent => $node[$parent]), array($parent => $node[$model->primaryKey])); $model->updateAll(array($parent => $node[$parent]), array($parent => $node[$model->primaryKey]));
$this->__sync($model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1)); $this->__sync($model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
$this->__sync($model, 2, '-', '> ' . ($node[$right])); $this->__sync($model, 2, '-', '> ' . ($node[$right]));
@ -655,7 +670,11 @@ class TreeBehavior extends ModelBehavior {
if ($delete) { if ($delete) {
$model->updateAll( $model->updateAll(
array($model->escapeField($left) => 0, $model->escapeField($right) => 0, $model->escapeField($parent) => null), array(
$model->escapeField($left) => 0,
$model->escapeField($right) => 0,
$model->escapeField($parent) => null
),
array($model->escapeField() => $id) array($model->escapeField() => $id)
); );
return $model->delete($id); return $model->delete($id);
@ -705,7 +724,9 @@ class TreeBehavior extends ModelBehavior {
$errors = array(); $errors = array();
for ($i = $min; $i <= $edge; $i++) { for ($i = $min; $i <= $edge; $i++) {
$count = $model->find('count', array('conditions' => array($scope, 'OR' => array($model->escapeField($left) => $i, $model->escapeField($right) => $i)))); $count = $model->find('count', array('conditions' => array(
$scope, 'OR' => array($model->escapeField($left) => $i, $model->escapeField($right) => $i)
)));
if ($count != 1) { if ($count != 1) {
if ($count == 0) { if ($count == 0) {
$errors[] = array('index', $i, 'missing'); $errors[] = array('index', $i, 'missing');
@ -830,9 +851,9 @@ class TreeBehavior extends ModelBehavior {
} }
} }
list($edge) = array_values($model->find('first', array( list($edge) = array_values($model->find('first', array(
'conditions' => $scope, 'conditions' => $scope,
'fields' => $db->calculate($model, 'max', array($right)), 'fields' => $db->calculate($model, 'max', array($right)),
'recursive' => $recursive 'recursive' => $recursive
))); )));
return ife(empty ($edge[$right]), 0, $edge[$right]); return ife(empty ($edge[$right]), 0, $edge[$right]);
} }

View file

@ -220,7 +220,7 @@ class DboMysql extends DboSource {
return "''"; return "''";
} }
if (empty($column)) { if (empty($column)) {
$column = $this->introspectType($data); $column = $this->introspectType($data);
} }
switch ($column) { switch ($column) {

View file

@ -252,7 +252,7 @@ class DboPostgres extends DboSource {
return 'NULL'; return 'NULL';
} }
if (empty($column)) { if (empty($column)) {
$column = $this->introspectType($data); $column = $this->introspectType($data);
} }
switch($column) { switch($column) {
@ -261,20 +261,19 @@ class DboPostgres extends DboSource {
case 'integer': case 'integer':
if ($data === '') { if ($data === '') {
return 'DEFAULT'; return 'DEFAULT';
} else {
$data = pg_escape_string($data);
} }
break;
case 'binary': case 'binary':
$data = pg_escape_bytea($data); $data = pg_escape_bytea($data);
break; break;
case 'boolean': case 'boolean':
default:
if ($data === true) { if ($data === true) {
return 'TRUE'; return 'TRUE';
} elseif ($data === false) { } elseif ($data === false) {
return 'FALSE'; return 'FALSE';
} }
return 'DEFAULT';
break;
default:
$data = pg_escape_string($data); $data = pg_escape_string($data);
break; break;
} }

View file

@ -856,7 +856,7 @@ class Model extends Overloadable {
function getColumnTypes() { function getColumnTypes() {
$columns = $this->schema(); $columns = $this->schema();
if (empty($columns)) { if (empty($columns)) {
trigger_error(__('(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing schema()', true), E_USER_WARNING); trigger_error(__('(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing schema()', true), E_USER_WARNING);
} }
$cols = array(); $cols = array();
foreach ($columns as $field => $values) { foreach ($columns as $field => $values) {
@ -879,7 +879,7 @@ class Model extends Overloadable {
$column = str_replace(array($db->startQuote, $db->endQuote), '', $column); $column = str_replace(array($db->startQuote, $db->endQuote), '', $column);
if (strpos($column, '.')) { if (strpos($column, '.')) {
list($model, $column) = explode('.', $column); list($model, $column) = explode('.', $column);
} }
if ($model != $this->alias && isset($this->{$model})) { if ($model != $this->alias && isset($this->{$model})) {
return $this->{$model}->getColumnType($column); return $this->{$model}->getColumnType($column);
@ -1407,9 +1407,9 @@ class Model extends Overloadable {
} }
$_options = array_merge($options, array('atomic' => false)); $_options = array_merge($options, array('atomic' => false));
if ($_options['validate'] === 'first') { if ($_options['validate'] === 'first') {
$_options['validate'] = 'only'; $_options['validate'] = 'only';
} }
$_return = $this->{$association}->saveAll($values, $_options); $_return = $this->{$association}->saveAll($values, $_options);
if ($_return === false || (is_array($_return) && in_array(false, $_return, true))) { if ($_return === false || (is_array($_return) && in_array(false, $_return, true))) {
@ -1417,14 +1417,14 @@ class Model extends Overloadable {
$validates = false; $validates = false;
} }
if (is_array($_return)) { if (is_array($_return)) {
foreach ($_return as $val) { foreach ($_return as $val) {
if (!isset($return[$association])) { if (!isset($return[$association])) {
$return[$association] = array(); $return[$association] = array();
} elseif (!is_array($return[$association])) { } elseif (!is_array($return[$association])) {
$return[$association] = array($return[$association]); $return[$association] = array($return[$association]);
} }
$return[$association][] = $val; $return[$association][] = $val;
} }
} else { } else {
$return[$association] = $_return; $return[$association] = $_return;
} }
@ -2131,7 +2131,7 @@ class Model extends Overloadable {
if (isset($data[$this->alias])) { if (isset($data[$this->alias])) {
$data = $data[$this->alias]; $data = $data[$this->alias];
} elseif (!is_array($data)) { } elseif (!is_array($data)) {
$data = array(); $data = array();
} }
$Validation =& Validation::getInstance(); $Validation =& Validation::getInstance();

View file

@ -129,9 +129,9 @@ class String extends Object {
* @static * @static
*/ */
function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')') { function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')') {
if(empty($data) || is_array($data)) { if(empty($data) || is_array($data)) {
return $data; return $data;
} }
$depth = 0; $depth = 0;
$offset = 0; $offset = 0;

View file

@ -610,18 +610,19 @@ class Validation extends Object {
* @return boolean Success * @return boolean Success
* @access public * @access public
*/ */
function money($check, $symbolPosition = 'left') { function money($check, $symbolPosition = 'left') {
$_this =& Validation::getInstance(); $_this =& Validation::getInstance();
$_this->check = $check; $_this->check = $check;
switch ($symbolPosition) {
case 'left': switch ($symbolPosition) {
$_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u'; case 'left':
break; $_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
case 'right': break;
$_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u'; case 'right':
break; $_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
} break;
return $_this->_check(); }
return $_this->_check();
} }
/** /**
* Validate a multiple select. * Validate a multiple select.
@ -632,7 +633,7 @@ class Validation extends Object {
* @access public * @access public
* @todo Implement * @todo Implement
*/ */
function multiple($check, $type, $regex = null) { function multiple($check, $type, $regex = null) {
//Validate a select object for a selected index past 0. //Validate a select object for a selected index past 0.
//Validate a select against a list of restriced indexes. //Validate a select against a list of restriced indexes.
//Validate a multiple-select for the quantity selected. //Validate a multiple-select for the quantity selected.
@ -671,7 +672,7 @@ class Validation extends Object {
case 'us': case 'us':
default: default:
$_this->regex = '/^1?[-. ]?\\(?([0-9]{3})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/'; $_this->regex = '/^1?[-. ]?\\(?([0-9]{3})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/';
break; break;
} }
} }
return $_this->_check(); return $_this->_check();

View file

@ -490,17 +490,18 @@ class HtmlHelper extends AppHelper {
$useCount = true; $useCount = true;
$oddTrOptions = null; $oddTrOptions = null;
} }
if ($evenTrOptions === false) { if ($evenTrOptions === false) {
$continueOddEven = false; $continueOddEven = false;
$evenTrOptions = null; $evenTrOptions = null;
} }
if ($continueOddEven) { if ($continueOddEven) {
static $count = 0; static $count = 0;
} else { } else {
$count = 0; $count = 0;
} }
foreach ($data as $line) { foreach ($data as $line) {
$count++; $count++;
$cellsOut = array(); $cellsOut = array();
@ -531,7 +532,7 @@ class HtmlHelper extends AppHelper {
* @param boolean $escape If true, $text will be HTML-escaped * @param boolean $escape If true, $text will be HTML-escaped
* @return string The formatted tag element * @return string The formatted tag element
*/ */
function tag($name, $text = null, $attributes = array(), $escape = false) { function tag($name, $text = null, $attributes = array(), $escape = false) {
if ($escape) { if ($escape) {
$text = h($text); $text = h($text);
} }
@ -661,9 +662,9 @@ class HtmlHelper extends AppHelper {
foreach ($options as $optValue => $optTitle) { foreach ($options as $optValue => $optTitle) {
$optionsHere = array('value' => $optValue); $optionsHere = array('value' => $optValue);
if (!empty($value) && $optValue == $value) { if (!empty($value) && $optValue == $value) {
$optionsHere['checked'] = 'checked'; $optionsHere['checked'] = 'checked';
} }
$parsedOptions = $this->_parseAttributes(array_merge($htmlAttributes, $optionsHere), null, '', ' '); $parsedOptions = $this->_parseAttributes(array_merge($htmlAttributes, $optionsHere), null, '', ' ');
$individualTagName = $this->field() . "_{$optValue}"; $individualTagName = $this->field() . "_{$optValue}";
$out[] = sprintf($this->tags['radio'], $this->model(), $this->field(), $individualTagName, $parsedOptions, $optTitle); $out[] = sprintf($this->tags['radio'], $this->model(), $this->field(), $individualTagName, $parsedOptions, $optTitle);

View file

@ -133,11 +133,11 @@ class SessionHelper extends CakeSession {
$flash = parent::read('Message.' . $key); $flash = parent::read('Message.' . $key);
if ($flash['layout'] == 'default') { if ($flash['layout'] == 'default') {
if (!empty($flash['params']['class'])) { if (!empty($flash['params']['class'])) {
$class = $flash['params']['class']; $class = $flash['params']['class'];
} else { } else {
$class = 'message'; $class = 'message';
} }
$out = '<div id="' . $key . 'Message" class="' . $class . '">' . $flash['message'] . '</div>'; $out = '<div id="' . $key . 'Message" class="' . $class . '">' . $flash['message'] . '</div>';
} elseif ($flash['layout'] == '' || $flash['layout'] == null) { } elseif ($flash['layout'] == '' || $flash['layout'] == null) {
$out = $flash['message']; $out = $flash['message'];

View file

@ -298,7 +298,7 @@ class DispatcherTest extends UnitTestCase {
array('data' => ''), array('data' => ''),
), ),
'Post' => array('attachment' => 'application/x-javascript'), 'Post' => array('attachment' => 'application/x-javascript'),
), ),
'tmp_name' => array( 'tmp_name' => array(
'File' => array( 'File' => array(
array('data' => '/private/var/tmp/phpy05Ywj'), array('data' => '/private/var/tmp/phpy05Ywj'),
@ -316,8 +316,8 @@ class DispatcherTest extends UnitTestCase {
array('data' => 4) array('data' => 4)
), ),
'Post' => array('attachment' => 0) 'Post' => array('attachment' => 0)
), ),
'size' => array( 'size' => array(
'File' => array( 'File' => array(
array('data' => 6271), array('data' => 6271),
array('data' => 350), array('data' => 350),
@ -341,7 +341,7 @@ class DispatcherTest extends UnitTestCase {
'size' => 6271, 'size' => 6271,
), ),
), ),
array('data' => array( array('data' => array(
'name' => 'controller.diff', 'name' => 'controller.diff',
'type' => '', 'type' => '',
'tmp_name' => '/private/var/tmp/php7MBztY', 'tmp_name' => '/private/var/tmp/php7MBztY',

View file

@ -66,7 +66,7 @@ class CodeCoverageManagerTest extends UnitTestCase {
$contents = $folder->ls(); $contents = $folder->ls();
function remove($var) { function remove($var) {
return ($var != basename(__FILE__)); return ($var != basename(__FILE__));
} }
$contents[1] = array_filter($contents[1], "remove"); $contents[1] = array_filter($contents[1], "remove");

View file

@ -295,37 +295,37 @@ class AclComponentTest extends CakeTestCase {
$result = $this->Acl->_Instance->readConfigFile($iniFile); $result = $this->Acl->_Instance->readConfigFile($iniFile);
$expected = array( $expected = array(
'admin' => array( 'admin' => array(
'groups' => 'administrators', 'groups' => 'administrators',
'allow' => '', 'allow' => '',
'deny' => 'ads', 'deny' => 'ads',
), ),
'paul' => array( 'paul' => array(
'groups' => 'users', 'groups' => 'users',
'allow' =>'', 'allow' =>'',
'deny' => '', 'deny' => '',
), ),
'jenny' => array( 'jenny' => array(
'groups' => 'users', 'groups' => 'users',
'allow' => 'ads', 'allow' => 'ads',
'deny' => 'images, files', 'deny' => 'images, files',
), ),
'nobody' => array( 'nobody' => array(
'groups' => 'anonymous', 'groups' => 'anonymous',
'allow' => '', 'allow' => '',
'deny' => '', 'deny' => '',
), ),
'administrators' => array( 'administrators' => array(
'deny' => '', 'deny' => '',
'allow' => 'posts, comments, images, files, stats, ads', 'allow' => 'posts, comments, images, files, stats, ads',
), ),
'users' => array( 'users' => array(
'allow' => 'posts, comments, images, files', 'allow' => 'posts, comments, images, files',
'deny' => 'stats, ads', 'deny' => 'stats, ads',
), ),
'anonymous' => array( 'anonymous' => array(
'allow' => '', 'allow' => '',
'deny' => 'posts, comments, images, files, stats, ads', 'deny' => 'posts, comments, images, files, stats, ads',
), ),
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }

View file

@ -51,7 +51,7 @@ class EmailTest extends CakeTestCase {
function testBadSmtpSend() { function testBadSmtpSend() {
if (@fsockopen('localhost', 25)) { if (@fsockopen('localhost', 25)) {
$this->Controller->Email->smtpOptions['host'] = 'blah'; $this->Controller->Email->smtpOptions['host'] = 'blah';
$this->Controller->Email->delivery = 'smtp'; $this->Controller->Email->delivery = 'smtp';
$this->assertFalse($this->Controller->Email->send('Should not work')); $this->assertFalse($this->Controller->Email->send('Should not work'));
} else { } else {
$this->skipUnless(@fsockopen('localhost', 25), 'Must be able to connect to localhost port 25'); $this->skipUnless(@fsockopen('localhost', 25), 'Must be able to connect to localhost port 25');

View file

@ -275,7 +275,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
unset($this->RequestHandler); unset($this->RequestHandler);
unset($this->Controller); unset($this->Controller);
if (!headers_sent()) { if (!headers_sent()) {
header('Content-type: text/html'); //reset content type. header('Content-type: text/html'); //reset content type.
} }
} }
} }

View file

@ -58,9 +58,6 @@ class ScaffoldViewTest extends CakeTestCase {
$this->Controller = new ScaffoldMockController(); $this->Controller = new ScaffoldMockController();
} }
function tearDown() {
unset($this->Controller);
}
function testGetViewFilename() { function testGetViewFilename() {
$this->Controller->action = 'index'; $this->Controller->action = 'index';
$ScaffoldView =& new TestScaffoldView($this->Controller); $ScaffoldView =& new TestScaffoldView($this->Controller);
@ -68,10 +65,14 @@ class ScaffoldViewTest extends CakeTestCase {
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp'; $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('error'); $result = $ScaffoldView->testGetFilename('error');
$expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp'; $expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function tearDown() {
unset($this->Controller);
}
} }
?> ?>

View file

@ -97,10 +97,10 @@ class DebuggerTest extends UnitTestCase {
set_error_handler('simpleTestErrorHandler'); set_error_handler('simpleTestErrorHandler');
} }
function testTrimPath() { function testTrimPath() {
$this->assertEqual(Debugger::trimPath(APP), 'APP/'); $this->assertEqual(Debugger::trimPath(APP), 'APP/');
$this->assertEqual(Debugger::trimPath(CAKE_CORE_INCLUDE_PATH), 'CORE'); $this->assertEqual(Debugger::trimPath(CAKE_CORE_INCLUDE_PATH), 'CORE');
} }
function testExportVar() { function testExportVar() {
App::import('Controller'); App::import('Controller');

View file

@ -65,7 +65,7 @@ class NumberTree extends CakeTestModel {
} }
class FlagTree extends NumberTree { class FlagTree extends NumberTree {
var $name = 'FlagTree'; var $name = 'FlagTree';
} }
class Campaign extends CakeTestModel { class Campaign extends CakeTestModel {
@ -124,7 +124,7 @@ class NumberTreeCase extends CakeTestCase {
$this->assertEqual($this->FlagTree->find('count'), 11); $this->assertEqual($this->FlagTree->find('count'), 11);
} }
function testArrayScope() { function testArrayScope() {
$this->FlagTree =& new FlagTree(); $this->FlagTree =& new FlagTree();
$this->FlagTree->__initialize(2, 3); $this->FlagTree->__initialize(2, 3);
@ -155,7 +155,7 @@ class NumberTreeCase extends CakeTestCase {
$this->assertEqual($this->FlagTree->find('count'), 11); $this->assertEqual($this->FlagTree->find('count'), 11);
} }
function testDetectInvalidLeft() { function testDetectInvalidLeft() {
$this->NumberTree =& new NumberTree(); $this->NumberTree =& new NumberTree();
$this->NumberTree->__initialize(2, 2); $this->NumberTree->__initialize(2, 2);

View file

@ -195,7 +195,7 @@ class DboMysqlTest extends CakeTestCase {
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); $this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
$this->model = new CakeTestModel(array( $this->model = new CakeTestModel(array(
'name' => 'Tinyint', 'table' => $this->db->fullTableName('tinyint', false) 'name' => 'Tinyint', 'table' => $this->db->fullTableName('tinyint', false)
)); ));
$result = $this->model->schema(); $result = $this->model->schema();
$this->assertEqual($result['bool']['type'], 'boolean'); $this->assertEqual($result['bool']['type'], 'boolean');

View file

@ -42,8 +42,8 @@ if (!class_exists('RequestActionController')) {
} }
class TestObject extends Object { class TestObject extends Object {
var $firstName = 'Joel'; var $firstName = 'Joel';
var $lastName = 'Moss'; var $lastName = 'Moss';
var $methodCalls = array(); var $methodCalls = array();
function emptyMethod() { function emptyMethod() {
@ -92,10 +92,10 @@ class ObjectTest extends UnitTestCase {
$this->object = new TestObject(); $this->object = new TestObject();
} }
function testLog() { function testLog() {
@unlink(LOGS . 'error.log'); @unlink(LOGS . 'error.log');
$this->assertTrue($this->object->log('Test warning 1')); $this->assertTrue($this->object->log('Test warning 1'));
$this->assertTrue($this->object->log(array('Test' => 'warning 2'))); $this->assertTrue($this->object->log(array('Test' => 'warning 2')));
$result = file(LOGS . 'error.log'); $result = file(LOGS . 'error.log');
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Test warning 1$/', $result[0]); $this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Test warning 1$/', $result[0]);
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Array$/', $result[1]); $this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Array$/', $result[1]);
@ -103,7 +103,7 @@ class ObjectTest extends UnitTestCase {
$this->assertPattern('/\[Test\] => warning 2$/', $result[3]); $this->assertPattern('/\[Test\] => warning 2$/', $result[3]);
$this->assertPattern('/^\)$/', $result[4]); $this->assertPattern('/^\)$/', $result[4]);
unlink(LOGS . 'error.log'); unlink(LOGS . 'error.log');
@unlink(LOGS . 'error.log'); @unlink(LOGS . 'error.log');
$this->assertTrue($this->object->log('Test warning 1', LOG_WARNING)); $this->assertTrue($this->object->log('Test warning 1', LOG_WARNING));
$this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING)); $this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING));