Merge branch 'local/svn/1.2.x.x' into 1.2

This commit is contained in:
gwoo 2009-06-02 10:11:21 -07:00
commit 5749893326
30 changed files with 628 additions and 126 deletions

View file

@ -205,7 +205,7 @@ class AclShell extends Shell {
extract($this->__dataVars());
$data = array(
$class => array(
'id' => $this->args[1],
'id' => $this->args[1],
'parent_id' => $this->args[2]
)
);
@ -336,7 +336,12 @@ class AclShell extends Shell {
}
$last = $n[$class]['rght'];
$count = count($stack);
$this->out(str_repeat(' ', $count) . "[" . $n[$class]['id'] . "]" . $n[$class]['alias']."\n");
$indent = str_repeat(' ', $count);
if ($n[$class]['alias']) {
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['alias']."\n");
} else {
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['model'] . '.' . $n[$class]['foreign_key'] . "\n");
}
}
$this->hr();
}

View file

@ -281,7 +281,7 @@ class DbConfigTask extends Shell {
if ($info['persistent'] === false) {
$info['persistent'] = 'false';
} else {
$info['persistent'] = 'false';
$info['persistent'] = ($info['persistent'] == true) ? 'true' : 'false';
}
$oldConfigs[] = array(

View file

@ -50,16 +50,16 @@
<div class="actions">
<ul>
<?php if ($action != 'add'):?>
<li><?php echo "<?php echo \$html->link(__('Delete', true), array('action'=>'delete', \$form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
<li><?php echo "<?php echo \$html->link(__('Delete', true), array('action' => 'delete', \$form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
<?php endif;?>
<li><?php echo "<?php echo \$html->link(__('List {$pluralHumanName}', true), array('action'=>'index'));?>";?></li>
<li><?php echo "<?php echo \$html->link(__('List {$pluralHumanName}', true), array('action' => 'index'));?>";?></li>
<?php
$done = array();
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}

View file

@ -54,7 +54,7 @@ foreach (\${$pluralVar} as \${$singularVar}):
foreach ($associations['belongsTo'] as $alias => $details) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<td>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller'=> '{$details['controller']}', 'action'=>'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t</td>\n";
echo "\t\t<td>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t</td>\n";
break;
}
}
@ -65,9 +65,9 @@ foreach (\${$pluralVar} as \${$singularVar}):
}
echo "\t\t<td class=\"actions\">\n";
echo "\t\t\t<?php echo \$html->link(__('View', true), array('action'=>'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\t<?php echo \$html->link(__('Edit', true), array('action'=>'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\t<?php echo \$html->link(__('Delete', true), array('action'=>'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\t<?php echo \$html->link(__('View', true), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\t<?php echo \$html->link(__('Edit', true), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\t<?php echo \$html->link(__('Delete', true), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
@ -78,18 +78,18 @@ echo "<?php endforeach; ?>\n";
<div class="paging">
<?php echo "\t<?php echo \$paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?>
| <?php echo "\t<?php echo \$paginator->numbers();?>\n"?>
<?php echo "\t<?php echo \$paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>\n";?>
<?php echo "\t<?php echo \$paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>\n";?>
</div>
<div class="actions">
<ul>
<li><?php echo "<?php echo \$html->link(__('New {$singularHumanName}', true), array('action'=>'add')); ?>";?></li>
<li><?php echo "<?php echo \$html->link(__('New {$singularHumanName}', true), array('action' => 'add')); ?>";?></li>
<?php
$done = array();
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}

View file

@ -33,7 +33,7 @@ foreach ($fields as $field) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller'=> '{$details['controller']}', 'action'=>'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
break;
}
}
@ -49,17 +49,17 @@ foreach ($fields as $field) {
<div class="actions">
<ul>
<?php
echo "\t\t<li><?php echo \$html->link(__('Edit {$singularHumanName}', true), array('action'=>'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('Delete {$singularHumanName}', true), array('action'=>'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('List {$pluralHumanName}', true), array('action'=>'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New {$singularHumanName}', true), array('action'=>'add')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('Edit {$singularHumanName}', true), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('Delete {$singularHumanName}', true), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('List {$pluralHumanName}', true), array('action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New {$singularHumanName}', true), array('action' => 'add')); ?> </li>\n";
$done = array();
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}
@ -84,7 +84,7 @@ if (!empty($associations['hasOne'])) :
<?php echo "<?php endif; ?>\n";?>
<div class="actions">
<ul>
<li><?php echo "<?php echo \$html->link(__('Edit ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
<li><?php echo "<?php echo \$html->link(__('Edit ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
</ul>
</div>
</div>
@ -131,9 +131,9 @@ echo "\t<?php
}
echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t<?php echo \$html->link(__('View', true), array('controller'=> '{$details['controller']}', 'action'=>'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$html->link(__('Edit', true), array('controller'=> '{$details['controller']}', 'action'=>'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$html->link(__('Delete', true), array('controller'=> '{$details['controller']}', 'action'=>'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$html->link(__('View', true), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$html->link(__('Edit', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$html->link(__('Delete', true), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";
@ -143,7 +143,7 @@ echo "\t<?php endforeach; ?>\n";
<?php echo "<?php endif; ?>\n\n";?>
<div class="actions">
<ul>
<li><?php echo "<?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add'));?>";?> </li>
<li><?php echo "<?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
</ul>
</div>
</div>

View file

@ -339,7 +339,7 @@ class AuthComponent extends Object {
$this->Session->setFlash($this->authError, 'default', array(), 'auth');
if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) {
$query = $controller->params['url'];
unset($query['url']);
unset($query['url'], $query['ext']);
$url .= Router::queryString($query, array());
}
$this->Session->write('Auth.redirect', $url);

View file

@ -161,8 +161,8 @@ class Scaffold extends Object {
$displayField = $this->ScaffoldModel->displayField;
$singularVar = Inflector::variable($modelClass);
$pluralVar = Inflector::variable($this->controller->name);
$singularHumanName = Inflector::humanize($modelClass);
$pluralHumanName = Inflector::humanize($this->controller->name);
$singularHumanName = Inflector::humanize(Inflector::underscore($modelClass));
$pluralHumanName = Inflector::humanize(Inflector::underscore($this->controller->name));
$scaffoldFields = array_keys($this->ScaffoldModel->schema());
$associations = $this->__associations();

View file

@ -249,16 +249,16 @@ class Inflector extends Object {
$_this->pluralRules['regexIrregular'] = $regexIrregular;
}
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->pluralized[$word];
}
if (preg_match('/^(' . $regexUninflected . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $word;
return $word;
}
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->pluralized[$word];
}
foreach ($pluralRules as $rule => $replacement) {
if (preg_match($rule, $word)) {
$_this->pluralized[$word] = preg_replace($rule, $replacement, $word);
@ -385,16 +385,16 @@ class Inflector extends Object {
$_this->singularRules['regexIrregular'] = $regexIrregular;
}
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
$_this->singularized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->singularized[$word];
}
if (preg_match('/^(' . $regexUninflected . ')$/i', $word, $regs)) {
$_this->singularized[$word] = $word;
return $word;
}
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
$_this->singularized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->singularized[$word];
}
foreach ($singularRules as $rule => $replacement) {
if (preg_match($rule, $word)) {
$_this->singularized[$word] = preg_replace($rule, $replacement, $word);

View file

@ -877,9 +877,10 @@ class TreeBehavior extends ModelBehavior {
$scope['NOT'][$Model->alias . '.' . $Model->primaryKey] = $Model->id;
}
}
$name = $Model->alias . '.' . $right;
list($edge) = array_values($Model->find('first', array(
'conditions' => $scope,
'fields' => $db->calculate($Model, 'max', array($right)),
'fields' => $db->calculate($Model, 'max', array($name, $right)),
'recursive' => $recursive
)));
return (empty($edge[$right])) ? 0 : $edge[$right];
@ -895,9 +896,10 @@ class TreeBehavior extends ModelBehavior {
*/
function __getMin($Model, $scope, $left, $recursive = -1) {
$db =& ConnectionManager::getDataSource($Model->useDbConfig);
$name = $Model->alias . '.' . $left;
list($edge) = array_values($Model->find('first', array(
'conditions' => $scope,
'fields' => $db->calculate($Model, 'min', array($left)),
'fields' => $db->calculate($Model, 'min', array($name, $left)),
'recursive' => $recursive
)));
return (empty($edge[$left])) ? 0 : $edge[$left];

View file

@ -384,7 +384,7 @@ class DboMssql extends DboSource {
$error = mssql_get_last_message($this->connection);
if ($error) {
if (!preg_match('/contexto de la base de datos a|contesto di database|changed database/i', $error)) {
if (!preg_match('/contexto de la base de datos a|contesto di database|changed database|datenbankkontext/i', $error)) {
return $error;
}
}

View file

@ -88,7 +88,7 @@ class DboSqlite extends DboSource {
'primary_key' => array('name' => 'integer primary key'),
'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'),
'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),
'integer' => array('name' => 'integer', 'limit' => 11, 'formatter' => 'intval'),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
@ -190,18 +190,19 @@ class DboSqlite extends DboSource {
foreach ($result as $column) {
$fields[$column[0]['name']] = array(
'type' => $this->column($column[0]['type']),
'null' => !$column[0]['notnull'],
'default' => $column[0]['dflt_value'],
'length' => $this->length($column[0]['type'])
'type' => $this->column($column[0]['type']),
'null' => !$column[0]['notnull'],
'default' => $column[0]['dflt_value'],
'length' => $this->length($column[0]['type'])
);
if ($column[0]['pk'] == 1) {
$colLength = $this->length($column[0]['type']);
$fields[$column[0]['name']] = array(
'type' => $fields[$column[0]['name']]['type'],
'null' => false,
'default' => $column[0]['dflt_value'],
'key' => $this->index['PRI'],
'length' => 11
'type' => $fields[$column[0]['name']]['type'],
'null' => false,
'default' => $column[0]['dflt_value'],
'key' => $this->index['PRI'],
'length'=> ($colLength != null) ? $colLength : 11
);
}
}
@ -449,34 +450,34 @@ class DboSqlite extends DboSource {
}
$real = $this->columns[$type];
if (isset($column['key']) && $column['key'] == 'primary') {
$out = $this->name($name) . ' ' . $this->columns['primary_key']['name'];
} else {
$out = $this->name($name) . ' ' . $real['name'];
if (isset($real['limit']) || isset($real['length']) || isset($column['limit']) || isset($column['length'])) {
if (isset($column['length'])) {
$length = $column['length'];
} elseif (isset($column['limit'])) {
$length = $column['limit'];
} elseif (isset($real['length'])) {
$length = $real['length'];
} else {
$length = $real['limit'];
}
$out .= '(' . $length . ')';
}
if (isset($column['key']) && $column['key'] == 'primary') {
$out .= ' NOT NULL';
} elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
} elseif (isset($column['default'])) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type);
} elseif (isset($column['null']) && $column['null'] == true) {
$out .= ' DEFAULT NULL';
} elseif (isset($column['null']) && $column['null'] == false) {
$out .= ' NOT NULL';
$out = $this->name($name) . ' ' . $real['name'];
if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') {
return $this->name($name) . ' ' . $this->columns['primary_key']['name'];
}
if (isset($real['limit']) || isset($real['length']) || isset($column['limit']) || isset($column['length'])) {
if (isset($column['length'])) {
$length = $column['length'];
} elseif (isset($column['limit'])) {
$length = $column['limit'];
} elseif (isset($real['length'])) {
$length = $real['length'];
} else {
$length = $real['limit'];
}
$out .= '(' . $length . ')';
}
if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') {
$out .= ' ' . $this->columns['primary_key']['name'];
} elseif (isset($column['key']) && $column['key'] == 'primary') {
$out .= ' NOT NULL';
} elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL';
} elseif (isset($column['default'])) {
$out .= ' DEFAULT ' . $this->value($column['default'], $type);
} elseif (isset($column['null']) && $column['null'] == true) {
$out .= ' DEFAULT NULL';
} elseif (isset($column['null']) && $column['null'] == false) {
$out .= ' NOT NULL';
}
return $out;
}

View file

@ -815,13 +815,18 @@ class Model extends Overloadable {
* @access public
*/
function deconstruct($field, $data) {
if (!is_array($data)) {
return $data;
}
$copy = $data;
$type = $this->getColumnType($field);
$db =& ConnectionManager::getDataSource($this->useDbConfig);
if (in_array($type, array('datetime', 'timestamp', 'date', 'time'))) {
$useNewDate = (isset($data['year']) || isset($data['month']) || isset($data['day']) || isset($data['hour']) || isset($data['minute']));
$dateFields = array('Y' => 'year', 'm' => 'month', 'd' => 'day', 'H' => 'hour', 'i' => 'min', 's' => 'sec');
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$format = $db->columns[$type]['format'];
$date = array();
@ -1380,7 +1385,7 @@ class Model extends Overloadable {
if ($keys['old'][$foreignKey] != $keys[$foreignKey]) {
$conditions[$fkQuoted] = $keys['old'][$foreignKey];
$count = intval($this->find('count', compact('conditions', 'recursive')));
$this->{$parent}->updateAll(
array($assoc['counterCache'] => $count),
array($this->{$parent}->escapeField() => $keys['old'][$foreignKey])
@ -2739,7 +2744,7 @@ class Model extends Overloadable {
function afterSave($created) {
}
/**
* Called after every deletion operation.
* Called before every deletion operation.
*
* @param boolean $cascade If true records that depend on this record will also be deleted
* @return boolean True if the operation should continue, false if it should abort

View file

@ -138,10 +138,8 @@ class CakeSession extends Object {
if ($start === true) {
$this->host = env('HTTP_HOST');
if (empty($base) || strpos($base, '?') === 0 || strpos($base, 'index.php') === 0) {
$this->path = '/';
} else {
$this->path = '/';
if (strpos($base, '?') === false && strpos($base, 'index.php') === false) {
$this->path = $base;
}

View file

@ -853,7 +853,7 @@ class FormHelper extends AppHelper {
'id' => $options['id'] . '_', 'name' => $options['name'],
'value' => '0', 'secure' => false
);
if (isset($options['disabled'])) {
if (isset($options['disabled']) && $options['disabled'] == true) {
$hiddenOptions['disabled'] = 'disabled';
}
$output = $this->hidden($fieldName, $hiddenOptions);

View file

@ -316,8 +316,10 @@ class HtmlHelper extends AppHelper {
/**
* Creates a link element for CSS stylesheets.
*
* @param mixed $path The name of a CSS style sheet in /app/webroot/css, or an array containing names of CSS stylesheets in that directory.
* @param string $rel Rel attribute. Defaults to "stylesheet".
* @param mixed $path The name of a CSS style sheet or an array containing names of
* CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot
* of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css.
* @param string $rel Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported.
* @param array $htmlAttributes Array of HTML attributes.
* @param boolean $inline If set to false, the generated tag appears in the head tag of the layout.
* @return string CSS <link /> or <style /> tag, depending on the type of link.

View file

@ -32,16 +32,16 @@
<div class="actions">
<ul>
<?php if ($this->action != 'add'):?>
<li><?php echo $html->link(__('Delete', true), array('action'=>'delete', $form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $form->value($modelClass.'.'.$primaryKey)); ?></li>
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $form->value($modelClass.'.'.$primaryKey)); ?></li>
<?php endif;?>
<li><?php echo $html->link(__('List', true).' '.$pluralHumanName, array('action'=>'index'));?></li>
<li><?php echo $html->link(__('List', true).' '.$pluralHumanName, array('action' => 'index'));?></li>
<?php
$done = array();
foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add'))."</li>\n";
$done[] = $_details['controller'];
}
}

View file

@ -51,7 +51,7 @@ echo "\n";
foreach ($associations['belongsTo'] as $_alias => $_details) {
if ($_field === $_details['foreignKey']) {
$isKey = true;
echo "\t\t<td>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller'=> $_details['controller'], 'action'=>'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t</td>\n";
echo "\t\t<td>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t</td>\n";
break;
}
}
@ -62,9 +62,9 @@ echo "\n";
}
echo "\t\t<td class=\"actions\">\n";
echo "\t\t\t" . $html->link(__('View', true), array('action'=>'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
echo "\t\t\t" . $html->link(__('Edit', true), array('action'=>'edit', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
echo "\t\t\t" . $html->link(__('Delete', true), array('action'=>'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey]) . "\n";
echo "\t\t\t" . $html->link(__('View', true), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
echo "\t\t\t" . $html->link(__('Edit', true), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
echo "\t\t\t" . $html->link(__('Delete', true), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey]) . "\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
@ -74,20 +74,20 @@ echo "\n";
</table>
</div>
<div class="paging">
<?php echo "\t" . $paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled')) . "\n";?>
<?php echo "\t" . $paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?>
| <?php echo $paginator->numbers() . "\n"?>
<?php echo "\t ". $paginator->next(__('next', true) .' >>', array(), null, array('class'=>'disabled')) . "\n";?>
<?php echo "\t ". $paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link('New '.$singularHumanName, array('action'=>'add')); ?></li>
<li><?php echo $html->link('New '.$singularHumanName, array('action' => 'add')); ?></li>
<?php
$done = array();
foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."</li>\n";
$done[] = $_details['controller'];
}
}

View file

@ -38,7 +38,7 @@ foreach ($scaffoldFields as $_field) {
if ($_field === $_details['foreignKey']) {
$isKey = true;
echo "\t\t<dt{$class}>".Inflector::humanize($_alias)."</dt>\n";
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller'=> $_details['controller'], 'action'=>'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n";
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n";
break;
}
}
@ -54,17 +54,17 @@ foreach ($scaffoldFields as $_field) {
<div class="actions">
<ul>
<?php
echo "\t\t<li>" .$html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action'=>'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('Delete %s', true), $singularHumanName), array('action'=>'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('List %s', true), $pluralHumanName), array('action'=>'index')). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('New %s', true), $singularHumanName), array('action'=>'add')). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('Delete %s', true), $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('List %s', true), $pluralHumanName), array('action' => 'index')). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')). " </li>\n";
$done = array();
foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'))."</li>\n";
$done[] = $_details['controller'];
}
}
@ -95,7 +95,7 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
<li><?php echo $html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
</ul>
</div>
</div>
@ -141,9 +141,9 @@ $otherSingularVar = Inflector::variable($_alias);
}
echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t" . $html->link(__('View', true), array('controller'=> $_details['controller'], 'action'=>'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $html->link(__('Edit', true), array('controller'=> $_details['controller'], 'action'=>'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $html->link(__('Delete', true), array('controller'=> $_details['controller'], 'action'=>'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
echo "\t\t\t\t" . $html->link(__('View', true), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $html->link(__('Edit', true), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $html->link(__('Delete', true), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";
endforeach;
@ -152,7 +152,7 @@ $otherSingularVar = Inflector::variable($_alias);
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'));?> </li>
<li><?php echo $html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
</ul>
</div>
</div>

View file

@ -0,0 +1,128 @@
<?php
/* SVN FILE: $Id$ */
/**
* AclShell Test file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2006-2008, Cake Software Foundation, Inc.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.tests.cases.console.libs.tasks
* @since CakePHP v 1.2.0.7726
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Core', 'Shell');
if (!defined('DISABLE_AUTO_DISPATCH')) {
define('DISABLE_AUTO_DISPATCH', true);
}
if (!class_exists('ShellDispatcher')) {
ob_start();
$argv = false;
require CAKE . 'console' . DS . 'cake.php';
ob_end_clean();
}
if (!class_exists('AclShell')) {
require CAKE . 'console' . DS . 'libs' . DS . 'acl.php';
}
Mock::generatePartial(
'ShellDispatcher', 'TestAclShellMockShellDispatcher',
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
);
Mock::generatePartial(
'AclShell', 'MockAclShell',
array('in', 'out', 'hr', 'createFile')
);
/**
* AclShellTest class
*
* @package cake
* @subpackage cake.tests.cases.console.libs.tasks
*/
class AclShellTest extends CakeTestCase {
var $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
/**
* configure Configure for testcase
*
* @return void
**/
function startCase() {
$this->_aclDb = Configure::read('Acl.database');
$this->_aclClass = Configure::read('Acl.classname');
Configure::write('Acl.database', 'test_suite');
Configure::write('Acl.classname', 'DbAcl');
}
/**
* restore Environment settings
*
* @return void
**/
function endCase() {
Configure::write('Acl.database', $this->_aclDb);
Configure::write('Acl.classname', $this->_aclClass);
}
/**
* setUp method
*
* @return void
* @access public
*/
function startTest() {
$this->Dispatcher =& new TestAclShellMockShellDispatcher();
$this->Task =& new MockAclShell($this->Dispatcher);
$this->Task->Dispatch = new $this->Dispatcher;
$this->Task->params['datasource'] = 'test_suite';
}
/**
* tearDown method
*
* @return void
* @access public
*/
function endTest() {
ClassRegistry::flush();
}
/**
* test that model.foreign_key output works when looking at acl rows
*
* @return void
**/
function testViewWithModelForeignKeyOutput() {
$this->Task->command = 'view';
$this->Task->startup();
$data = array(
'parent_id' => null,
'model' => 'MyModel',
'foreign_key' => 2,
);
$this->Task->Acl->Aro->create($data);
$this->Task->Acl->Aro->save();
$this->Task->args[0] = 'aro';
$this->Task->expectAt(0, 'out', array('Aro tree:'));
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/\[1\]ROOT/')));
$this->Task->expectAt(3, 'out', array(new PatternExpectation('/\[3\]Gandalf/')));
$this->Task->expectAt(5, 'out', array(new PatternExpectation('/\[5\]MyModel.2/')));
$this->Task->view();
}
}
?>

View file

@ -116,6 +116,9 @@ class CodeCoverageManagerTest extends CakeTestCase {
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('datasources/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'datasources'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('controllers/some_file.test.php', true);
$this->assertIdentical(APP.'controllers'.DS.'some_file.php', $expected);

View file

@ -728,6 +728,7 @@ class AuthTest extends CakeTestCase {
$this->Controller->params['action'] = 'Add';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
}
/**
* testLoginRedirect method
*
@ -854,6 +855,22 @@ class AuthTest extends CakeTestCase {
$this->Controller->Auth->startup($this->Controller);
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
$_GET = array(
'url' => '/posts/index/29',
'print' => 'true',
'refer' => 'menu',
'ext' => 'html'
);
$this->Controller->Session->del('Auth');
$url = '/posts/index/29?print=true&refer=menu';
$this->Controller->params = Dispatcher::parseParams($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->startup($this->Controller);
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
$_GET = $_back;
//external authed action

View file

@ -332,11 +332,11 @@ class ScaffoldViewTest extends CakeTestCase {
new Scaffold($this->Controller, $params);
$result = ob_get_clean();
$this->assertPattern('#<h2>ScaffoldMock</h2>#', $result);
$this->assertPattern('#<h2>Scaffold Mock</h2>#', $result);
$this->assertPattern('#<table cellpadding="0" cellspacing="0">#', $result);
//TODO: add testing for table generation
$this->assertPattern('#<a href="/scaffold_users/view/1">1</a>#', $result); //belongsTo links
$this->assertPattern('#<li><a href="/scaffold_mock/add/">New ScaffoldMock</a></li>#', $result);
$this->assertPattern('#<li><a href="/scaffold_mock/add/">New Scaffold Mock</a></li>#', $result);
$this->assertPattern('#<li><a href="/scaffold_users/">List Scaffold Users</a></li>#', $result);
$this->assertPattern('#<li><a href="/scaffold_comments/add/">New Comment</a></li>#', $result);
}
@ -371,12 +371,12 @@ class ScaffoldViewTest extends CakeTestCase {
new Scaffold($this->Controller, $params);
$result = ob_get_clean();
$this->assertPattern('/<h2>View ScaffoldMock<\/h2>/', $result);
$this->assertPattern('/<h2>View Scaffold Mock<\/h2>/', $result);
$this->assertPattern('/<dl>/', $result);
//TODO: add specific tests for fields.
$this->assertPattern('/<a href="\/scaffold_users\/view\/1">1<\/a>/', $result); //belongsTo links
$this->assertPattern('/<li><a href="\/scaffold_mock\/edit\/1">Edit ScaffoldMock<\/a>\s<\/li>/', $result);
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete ScaffoldMock<\/a>\s*<\/li>/', $result);
$this->assertPattern('/<li><a href="\/scaffold_mock\/edit\/1">Edit Scaffold Mock<\/a>\s<\/li>/', $result);
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete Scaffold Mock<\/a>\s*<\/li>/', $result);
//check related table
$this->assertPattern('/<div class="related">\s*<h3>Related Scaffold Comments<\/h3>\s*<table cellpadding="0" cellspacing="0">/', $result);
$this->assertPattern('/<li><a href="\/scaffold_comments\/add\/">New Comment<\/a><\/li>/', $result);
@ -459,10 +459,10 @@ class ScaffoldViewTest extends CakeTestCase {
$Scaffold = new Scaffold($this->Controller, $params);
$result = ob_get_clean();
$this->assertPattern('/<h2>ScaffoldMock<\/h2>/', $result);
$this->assertPattern('/<h2>Scaffold Mock<\/h2>/', $result);
$this->assertPattern('/<table cellpadding="0" cellspacing="0">/', $result);
//TODO: add testing for table generation
$this->assertPattern('/<li><a href="\/admin\/scaffold_mock\/add\/">New ScaffoldMock<\/a><\/li>/', $result);
$this->assertPattern('/<li><a href="\/admin\/scaffold_mock\/add\/">New Scaffold Mock<\/a><\/li>/', $result);
Configure::write('Routing.admin', $_backAdmin);
}
@ -580,5 +580,44 @@ class ScaffoldTest extends CakeTestCase {
$result = $Scaffold->getParams();
$this->assertEqual($result['action'], 'admin_edit');
}
/**
* test that the proper names and variable values are set by Scaffold
*
* @return void
**/
function testScaffoldVariableSetting() {
$this->Controller->action = 'admin_edit';
$this->Controller->here = '/admin/scaffold_mock/edit';
$this->Controller->webroot = '/';
$params = array(
'plugin' => null,
'pass' => array(),
'form' => array(),
'named' => array(),
'url' => array('url' =>'admin/scaffold_mock/edit'),
'controller' => 'scaffold_mock',
'action' => 'admin_edit',
'admin' => true,
);
//set router.
Router::setRequestInfo(array($params, array('base' => '/', 'here' => 'admin/scaffold_mock', 'webroot' => '/')));
$this->Controller->params = $params;
$this->Controller->controller = 'scaffold_mock';
$this->Controller->base = '/';
$this->Controller->constructClasses();
$Scaffold =& new TestScaffoldMock($this->Controller, $params);
$result = $this->Controller->viewVars;
$this->assertEqual($result['singularHumanName'], 'Scaffold Mock');
$this->assertEqual($result['pluralHumanName'], 'Scaffold Mock');
$this->assertEqual($result['modelClass'], 'ScaffoldMock');
$this->assertEqual($result['primaryKey'], 'id');
$this->assertEqual($result['displayField'], 'title');
$this->assertEqual($result['singularVar'], 'scaffoldMock');
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
}
}
?>

View file

@ -1229,7 +1229,7 @@ class ScopedTreeTest extends NumberTreeTest {
* @var array
* @access public
*/
var $fixtures = array('core.flag_tree', 'core.ad', 'core.campaign', 'core.translate');
var $fixtures = array('core.flag_tree', 'core.ad', 'core.campaign', 'core.translate', 'core.number_tree_two');
/**
* testStringScope method
*
@ -1433,6 +1433,61 @@ class ScopedTreeTest extends NumberTreeTest {
);
$this->assertEqual($result, $expected);
}
/**
* testGenerateTreeListWithSelfJoin method
*
* @return void
* @access public
*/
function testAliasesWithScopeInTwoTreeAssociations() {
extract($this->settings);
$this->Tree =& new $modelClass();
$this->Tree->initialize(2, 2);
$this->TreeTwo =& new NumberTreeTwo();
$record = $this->Tree->find('first');
$this->Tree->bindModel(array(
'hasMany' => array(
'SecondTree' => array(
'className' => 'NumberTreeTwo',
'foreignKey' => 'number_tree_id'
)
)
));
$this->TreeTwo->bindModel(array(
'belongsTo' => array(
'FirstTree' => array(
'className' => $modelClass,
'foreignKey' => 'number_tree_id'
)
)
));
$this->TreeTwo->Behaviors->attach('Tree', array(
'scope' => 'FirstTree'
));
$data = array(
'NumberTreeTwo' => array(
'name' => 'First',
'number_tree_id' => $record['FlagTree']['id']
)
);
$this->TreeTwo->create();
$this->assertTrue($this->TreeTwo->save($data));
$result = $this->TreeTwo->find('first');
$expected = array('NumberTreeTwo' => array(
'id' => 1,
'name' => 'First',
'number_tree_id' => $record['FlagTree']['id'],
'parent_id' => null,
'lft' => 1,
'rght' => 2
));
$this->assertEqual($result, $expected);
}
}
/**
* AfterTreeTest class

View file

@ -204,5 +204,69 @@ class DboSqliteTest extends CakeTestCase {
Cache::delete($fileName, '_cake_model_');
Configure::write('Cache.disable', true);
}
/**
* test describe() and normal results.
*
* @return void
**/
function testDescribe() {
$Model =& new Model(array('name' => 'User', 'ds' => 'test_suite', 'table' => 'users'));
$result = $this->db->describe($Model);
$expected = array(
'id' => array(
'type' => 'integer',
'key' => 'primary',
'null' => false,
'default' => null,
'length' => 11
),
'user' => array(
'type' => 'string',
'length' => 255,
'null' => false,
'default' => null
),
'password' => array(
'type' => 'string',
'length' => 255,
'null' => false,
'default' => null
),
'created' => array(
'type' => 'datetime',
'null' => true,
'default' => null,
'length' => null,
),
'updated' => array(
'type' => 'datetime',
'null' => true,
'default' => null,
'length' => null,
)
);
$this->assertEqual($result, $expected);
}
/**
* test that describe does not corrupt UUID primary keys
*
* @return void
**/
function testDescribeWithUuidPrimaryKey() {
$tableName = 'uuid_tests';
$this->db->query("CREATE TABLE {$tableName} (id VARCHAR(36) PRIMARY KEY, name VARCHAR, created DATETIME, modified DATETIME)");
$Model =& new Model(array('name' => 'UuidTest', 'ds' => 'test_suite', 'table' => 'uuid_tests'));
$result = $this->db->describe($Model);
$expected = array(
'type' => 'string',
'length' => 36,
'null' => false,
'default' => null,
'key' => 'primary',
);
$this->assertEqual($result['id'], $expected);
$this->db->query('DROP TABLE ' . $tableName);
}
}
?>

View file

@ -99,6 +99,49 @@ class ModelTest extends CakeTestCase {
function endTest() {
ClassRegistry::flush();
}
/**
* Tests getAssociated method
*
* @access public
* @return void
*/
function testGetAssociated() {
$this->loadFixtures('Article');
$Article = ClassRegistry::init('Article');
$assocTypes = array('hasMany', 'hasOne', 'belongsTo', 'hasAndBelongsToMany');
foreach ($assocTypes as $type) {
$this->assertEqual($Article->getAssociated($type), array_keys($Article->{$type}));
}
$Article->bindModel(array('hasMany' => array('Category')));
$this->assertEqual($Article->getAssociated('hasMany'), array('Comment', 'Category'));
$results = $Article->getAssociated();
$this->assertEqual(sort(array_keys($results)), array('Category', 'Comment', 'Tag'));
$Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')));
$this->assertEqual($Article->getAssociated('hasAndBelongsToMany'), array());
$result = $Article->getAssociated('Category');
$expected = array(
'className' => 'Category',
'foreignKey' => 'article_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'dependent' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => '',
'association' => 'hasMany',
);
$this->assertEqual($result, $expected);
}
/**
* testAutoConstructAssociations method
*
@ -1780,6 +1823,24 @@ class ModelTest extends CakeTestCase {
array('User' => array('id' => '4', 'user' => 'garrett'), 'Items' => array()));
$this->assertEqual($result, $expected);
}
/**
* test that bindModel behaves with Custom primary Key associations
*
* @return void
**/
function bindWithCustomPrimaryKey() {
$this->loadFixtures('Story', 'StoriesTag', 'Tag');
$Model =& ClassRegistry::init('StoriesTag');
$Model->bindModel(array(
'belongsTo' => array(
'Tag' => array('className' => 'Tag', 'foreignKey' => 'story')
)
));
$result = $Model->find('all');
$this->assertFalse(empty($result));
}
/**
* test find('count') method
*
@ -3990,10 +4051,10 @@ class ModelTest extends CakeTestCase {
$TestModel2->saveField('published', true);
$result = $TestModel->findById(1);
$this->assertIdentical($result['Syfile']['item_count'], '2');
$TestModel2->save(array('id' => 1, 'syfile_id' => 1, 'published'=> false));
$result = $TestModel->findById(1);
$this->assertIdentical($result['Syfile']['item_count'], '1');
$this->assertIdentical($result['Syfile']['item_count'], '1');
}
/**
* testDel method
@ -5845,6 +5906,19 @@ class ModelTest extends CakeTestCase {
$TestModel->set($data);
$expected = array('Apple'=> array('mytime'=> '03:04:04'));
$this->assertEqual($TestModel->data, $expected);
$db = ConnectionManager::getDataSource('test_suite');
$data = array();
$data['Apple']['modified'] = $db->expression('NOW()');
$TestModel->data = null;
$TestModel->set($data);
$this->assertEqual($TestModel->data, $data);
$data = array();
$data['Apple']['mytime'] = $db->expression('NOW()');
$TestModel->data = null;
$TestModel->set($data);
$this->assertEqual($TestModel->data, $data);
}
/**
* testTablePrefixSwitching method

View file

@ -2273,6 +2273,28 @@ class NumberTree extends CakeTestModel {
}
}
}
/**
* NumberTreeTwo class
*
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class NumberTreeTwo extends NumberTree {
/**
* name property
*
* @var string 'NumberTree'
* @access public
*/
var $name = 'NumberTreeTwo';
/**
* actsAs property
*
* @var array
* @access public
*/
var $actsAs = array();
}
/**
* FlagTree class
*

View file

@ -67,6 +67,16 @@ class SessionTest extends CakeTestCase {
$this->Session->start();
$this->Session->_checkValid();
}
/**
* testSessionPath
*
* @access public
* @return void
*/
function testSessionPath() {
$Session = new CakeSession('/index.php');
$this->assertEqual('/', $Session->path);
}
/**
* testCheck method
*

View file

@ -3165,6 +3165,21 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* Test that specifying false in the 'disabled' option will not disable either the hidden input or the checkbox input
*
* @return void
**/
function testCheckboxHiddenDisabling() {
$result = $this->Form->checkbox('Account.show_name', array('disabled' => false));
$expected = array(
array('input' => array('type' => 'hidden', 'name' => 'data[Account][show_name]', 'value' => '0', 'id' => 'AccountShowName_')),
array('input' => array('type' => 'checkbox', 'name' => 'data[Account][show_name]', 'value' => '1', 'id' => 'AccountShowName'))
);
$this->assertTags($result, $expected);
}
/**
* testDateTime method
*
@ -4355,6 +4370,9 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->button('Options', array('type' => 'reset', 'name' => 'Post.options', 'id' => 'Opt'));
$this->assertTags($result, array('input' => array('type' => 'reset', 'name' => 'data[Post][options]', 'id' => 'Opt', 'value' => 'Options')));
$result = $this->Form->button('Upload Text', array('onClick' => "$('#postAddForm').ajaxSubmit({target: '#postTextUpload', url: '/posts/text'});return false;'", 'escape' => false));
$this->assertNoPattern('/\&039/', $result);
}
/**
* testSubmitButton method

View file

@ -0,0 +1,58 @@
<?php
/* SVN FILE: $Id$ */
/**
* Tree behavior class.
*
* Enables a model object to act as a node-based tree.
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.fixtures
* @since CakePHP(tm) v 1.2.0.5331
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
/**
* Number Tree Test Fixture
*
* Generates a tree of data for use testing the tree behavior
*
* @package cake
* @subpackage cake.tests.fixtures
*/
class NumberTreeTwoFixture extends CakeTestFixture {
/**
* name property
*
* @var string 'NumberTree'
* @access public
*/
var $name = 'NumberTreeTwo';
/**
* fields property
*
* @var array
* @access public
*/
var $fields = array(
'id' => array('type' => 'integer','key' => 'primary'),
'name' => array('type' => 'string','null' => false),
'number_tree_id' => array('type' => 'integer', 'null' => false),
'parent_id' => 'integer',
'lft' => array('type' => 'integer','null' => false),
'rght' => array('type' => 'integer','null' => false)
);
}
?>

View file

@ -467,7 +467,8 @@ class CodeCoverageManager {
$folderPrefixMap = array(
'behaviors' => 'models',
'components' => 'controllers',
'helpers' => 'views'
'helpers' => 'views',
'datasources' => 'models'
);
foreach ($folderPrefixMap as $dir => $prefix) {