mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-04 18:42:40 +00:00
Merge branch '2.1' into 2.2
This commit is contained in:
commit
c9528b8446
13 changed files with 441 additions and 1142 deletions
|
@ -38,121 +38,11 @@ class TestsuiteShell extends TestShell {
|
|||
* @return void
|
||||
*/
|
||||
public function getOptionParser() {
|
||||
$parser = new ConsoleOptionParser($this->name);
|
||||
$parser = parent::getOptionParser();
|
||||
$parser->description(array(
|
||||
__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'),
|
||||
__d('cake_console', '<warning>This shell is for backwards-compatibility only</warning>'),
|
||||
__d('cake_console', 'use the test shell instead')
|
||||
))->addArgument('category', array(
|
||||
'help' => __d('cake_console', 'app, core or name of a plugin.'),
|
||||
'required' => true
|
||||
))->addArgument('file', array(
|
||||
'help' => __d('cake_console', 'file name with folder prefix and without the test.php suffix.'),
|
||||
'required' => false,
|
||||
))->addOption('log-junit', array(
|
||||
'help' => __d('cake_console', '<file> Log test execution in JUnit XML format to file.'),
|
||||
'default' => false
|
||||
))->addOption('log-json', array(
|
||||
'help' => __d('cake_console', '<file> Log test execution in JSON format to file.'),
|
||||
'default' => false
|
||||
))->addOption('log-tap', array(
|
||||
'help' => __d('cake_console', '<file> Log test execution in TAP format to file.'),
|
||||
'default' => false
|
||||
))->addOption('log-dbus', array(
|
||||
'help' => __d('cake_console', 'Log test execution to DBUS.'),
|
||||
'default' => false
|
||||
))->addOption('coverage-html', array(
|
||||
'help' => __d('cake_console', '<dir> Generate code coverage report in HTML format.'),
|
||||
'default' => false
|
||||
))->addOption('coverage-clover', array(
|
||||
'help' => __d('cake_console', '<file> Write code coverage data in Clover XML format.'),
|
||||
'default' => false
|
||||
))->addOption('testdox-html', array(
|
||||
'help' => __d('cake_console', '<file> Write agile documentation in HTML format to file.'),
|
||||
'default' => false
|
||||
))->addOption('testdox-text', array(
|
||||
'help' => __d('cake_console', '<file> Write agile documentation in Text format to file.'),
|
||||
'default' => false
|
||||
))->addOption('filter', array(
|
||||
'help' => __d('cake_console', '<pattern> Filter which tests to run.'),
|
||||
'default' => false
|
||||
))->addOption('group', array(
|
||||
'help' => __d('cake_console', '<name> Only runs tests from the specified group(s).'),
|
||||
'default' => false
|
||||
))->addOption('exclude-group', array(
|
||||
'help' => __d('cake_console', '<name> Exclude tests from the specified group(s).'),
|
||||
'default' => false
|
||||
))->addOption('list-groups', array(
|
||||
'help' => __d('cake_console', 'List available test groups.'),
|
||||
'boolean' => true
|
||||
))->addOption('loader', array(
|
||||
'help' => __d('cake_console', 'TestSuiteLoader implementation to use.'),
|
||||
'default' => false
|
||||
))->addOption('repeat', array(
|
||||
'help' => __d('cake_console', '<times> Runs the test(s) repeatedly.'),
|
||||
'default' => false
|
||||
))->addOption('tap', array(
|
||||
'help' => __d('cake_console', 'Report test execution progress in TAP format.'),
|
||||
'boolean' => true
|
||||
))->addOption('testdox', array(
|
||||
'help' => __d('cake_console', 'Report test execution progress in TestDox format.'),
|
||||
'default' => false,
|
||||
'boolean' => true
|
||||
))->addOption('no-colors', array(
|
||||
'help' => __d('cake_console', 'Do not use colors in output.'),
|
||||
'boolean' => true
|
||||
))->addOption('stderr', array(
|
||||
'help' => __d('cake_console', 'Write to STDERR instead of STDOUT.'),
|
||||
'boolean' => true
|
||||
))->addOption('stop-on-error', array(
|
||||
'help' => __d('cake_console', 'Stop execution upon first error or failure.'),
|
||||
'boolean' => true
|
||||
))->addOption('stop-on-failure', array(
|
||||
'help' => __d('cake_console', 'Stop execution upon first failure.'),
|
||||
'boolean' => true
|
||||
))->addOption('stop-on-skipped ', array(
|
||||
'help' => __d('cake_console', 'Stop execution upon first skipped test.'),
|
||||
'boolean' => true
|
||||
))->addOption('stop-on-incomplete', array(
|
||||
'help' => __d('cake_console', 'Stop execution upon first incomplete test.'),
|
||||
'boolean' => true
|
||||
))->addOption('strict', array(
|
||||
'help' => __d('cake_console', 'Mark a test as incomplete if no assertions are made.'),
|
||||
'boolean' => true
|
||||
))->addOption('wait', array(
|
||||
'help' => __d('cake_console', 'Waits for a keystroke after each test.'),
|
||||
'boolean' => true
|
||||
))->addOption('process-isolation', array(
|
||||
'help' => __d('cake_console', 'Run each test in a separate PHP process.'),
|
||||
'boolean' => true
|
||||
))->addOption('no-globals-backup', array(
|
||||
'help' => __d('cake_console', 'Do not backup and restore $GLOBALS for each test.'),
|
||||
'boolean' => true
|
||||
))->addOption('static-backup ', array(
|
||||
'help' => __d('cake_console', 'Backup and restore static attributes for each test.'),
|
||||
'boolean' => true
|
||||
))->addOption('syntax-check', array(
|
||||
'help' => __d('cake_console', 'Try to check source files for syntax errors.'),
|
||||
'boolean' => true
|
||||
))->addOption('bootstrap', array(
|
||||
'help' => __d('cake_console', '<file> A "bootstrap" PHP file that is run before the tests.'),
|
||||
'default' => false
|
||||
))->addOption('configuration', array(
|
||||
'help' => __d('cake_console', '<file> Read configuration from XML file.'),
|
||||
'default' => false
|
||||
))->addOption('no-configuration', array(
|
||||
'help' => __d('cake_console', 'Ignore default configuration file (phpunit.xml).'),
|
||||
'boolean' => true
|
||||
))->addOption('include-path', array(
|
||||
'help' => __d('cake_console', '<path(s)> Prepend PHP include_path with given path(s).'),
|
||||
'default' => false
|
||||
))->addOption('directive', array(
|
||||
'help' => __d('cake_console', 'key[=value] Sets a php.ini value.'),
|
||||
'default' => false
|
||||
))->addOption('fixture', array(
|
||||
'help' => __d('cake_console', 'Choose a custom fixture manager.'),
|
||||
))->addOption('debug', array(
|
||||
'help' => __d('cake_console', 'Enable full output of testsuite. (supported in PHPUnit 3.6.0 and greater)'),
|
||||
));
|
||||
|
||||
return $parser;
|
||||
|
|
|
@ -265,7 +265,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
public $methods = array();
|
||||
|
||||
/**
|
||||
* This controller's primary model class name, the Inflector::classify()'ed version of
|
||||
* This controller's primary model class name, the Inflector::singularize()'ed version of
|
||||
* the controller's $name property.
|
||||
*
|
||||
* Example: For a controller named 'Comments', the modelClass would be 'Comment'
|
||||
|
@ -363,9 +363,6 @@ class Controller extends Object implements CakeEventListener {
|
|||
foreach ($this->uses as $modelClass) {
|
||||
list($plugin, $class) = pluginSplit($modelClass, true);
|
||||
if ($name === $class) {
|
||||
if (!$plugin) {
|
||||
$plugin = $this->plugin ? $this->plugin . '.' : null;
|
||||
}
|
||||
return $this->loadModel($modelClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,13 @@ class TreeBehavior extends ModelBehavior {
|
|||
'scope' => '1 = 1', 'type' => 'nested', '__parentChange' => false, 'recursive' => -1
|
||||
);
|
||||
|
||||
/**
|
||||
* Used to preserve state between delete callbacks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_deletedRow = null;
|
||||
|
||||
/**
|
||||
* Initiate Tree behavior
|
||||
*
|
||||
|
@ -107,13 +114,13 @@ class TreeBehavior extends ModelBehavior {
|
|||
}
|
||||
|
||||
/**
|
||||
* Before delete method. Called before all deletes
|
||||
* Stores the record about to be deleted.
|
||||
*
|
||||
* Will delete the current node and all children using the deleteAll method and sync the table
|
||||
* This is used to delete child nodes in the afterDelete.
|
||||
*
|
||||
* @param Model $Model Model instance
|
||||
* @param boolean $cascade
|
||||
* @return boolean true to continue, false to abort the delete
|
||||
* @return boolean
|
||||
*/
|
||||
public function beforeDelete(Model $Model, $cascade = true) {
|
||||
extract($this->settings[$Model->alias]);
|
||||
|
@ -121,6 +128,22 @@ class TreeBehavior extends ModelBehavior {
|
|||
'conditions' => array($Model->alias . '.' . $Model->primaryKey => $Model->id),
|
||||
'fields' => array($Model->alias . '.' . $left, $Model->alias . '.' . $right),
|
||||
'recursive' => -1)));
|
||||
$this->_deletedRow = $data;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* After delete method.
|
||||
*
|
||||
* Will delete the current node and all children using the deleteAll method and sync the table
|
||||
*
|
||||
* @param Model $Model Model instance
|
||||
* @return boolean true to continue, false to abort the delete
|
||||
*/
|
||||
public function afterDelete(Model $Model) {
|
||||
extract($this->settings[$Model->alias]);
|
||||
$data = $this->_deletedRow;
|
||||
$this->_deletedRow = null;
|
||||
|
||||
if (!$data[$right] || !$data[$left]) {
|
||||
return true;
|
||||
|
|
|
@ -1853,6 +1853,8 @@ class DboSource extends DataSource {
|
|||
|
||||
if ($quoteValues) {
|
||||
$update .= $this->value($value, $model->getColumnType($field));
|
||||
} elseif ($model->getColumnType($field) == 'boolean') {
|
||||
$update .= $this->boolean($value, true);
|
||||
} elseif (!$alias) {
|
||||
$update .= str_replace($quotedAlias . '.', '', str_replace(
|
||||
$model->alias . '.', '', $value
|
||||
|
|
|
@ -2042,6 +2042,7 @@ class Model extends Object implements CakeEventListener {
|
|||
if ((!$validates && $options['atomic']) || (!$options['atomic'] && in_array(false, $validates, true))) {
|
||||
return $validates;
|
||||
}
|
||||
$options['validate'] = true;
|
||||
}
|
||||
|
||||
if ($options['atomic']) {
|
||||
|
@ -2172,6 +2173,7 @@ class Model extends Object implements CakeEventListener {
|
|||
if ((!$validates && $options['atomic']) || (!$options['atomic'] && in_array(false, $validates, true))) {
|
||||
return $validates;
|
||||
}
|
||||
$options['validate'] = true;
|
||||
}
|
||||
if ($options['atomic']) {
|
||||
$db = $this->getDataSource();
|
||||
|
@ -2193,10 +2195,11 @@ class Model extends Object implements CakeEventListener {
|
|||
$validates = ($saved === true || (is_array($saved) && !in_array(false, $saved, true)));
|
||||
}
|
||||
if ($validates) {
|
||||
if (!empty($data[$this->alias])) {
|
||||
$data[$this->alias][$this->belongsTo[$association]['foreignKey']] = $this->{$association}->id;
|
||||
$key = $this->belongsTo[$association]['foreignKey'];
|
||||
if (isset($data[$this->alias])) {
|
||||
$data[$this->alias][$key] = $this->{$association}->id;
|
||||
} else {
|
||||
$data[$this->belongsTo[$association]['foreignKey']] = $this->{$association}->id;
|
||||
$data = array_merge(array($key => $this->{$association}->id), $data, array($key => $this->{$association}->id));
|
||||
}
|
||||
} else {
|
||||
$validationErrors[$association] = $this->{$association}->validationErrors;
|
||||
|
@ -2216,9 +2219,14 @@ class Model extends Object implements CakeEventListener {
|
|||
}
|
||||
if (isset($associations[$association])) {
|
||||
$type = $associations[$association];
|
||||
$key = $this->{$type}[$association]['foreignKey'];
|
||||
switch ($type) {
|
||||
case 'hasOne':
|
||||
$values[$this->{$type}[$association]['foreignKey']] = $this->id;
|
||||
if (isset($values[$association])) {
|
||||
$values[$association][$key] = $this->id;
|
||||
} else {
|
||||
$values = array_merge(array($key => $this->id), $values, array($key => $this->id));
|
||||
}
|
||||
$validates = $this->{$association}->create(null) !== null;
|
||||
$saved = false;
|
||||
if ($validates) {
|
||||
|
@ -2236,7 +2244,11 @@ class Model extends Object implements CakeEventListener {
|
|||
break;
|
||||
case 'hasMany':
|
||||
foreach ($values as $i => $value) {
|
||||
$values[$i][$this->{$type}[$association]['foreignKey']] = $this->id;
|
||||
if (isset($values[$i][$association])) {
|
||||
$values[$i][$association][$key] = $this->id;
|
||||
} else {
|
||||
$values[$i] = array_merge(array($key => $this->id), $value, array($key => $this->id));
|
||||
}
|
||||
}
|
||||
$_return = $this->{$association}->saveMany($values, array_merge($options, array('atomic' => false)));
|
||||
if (in_array(false, $_return, true)) {
|
||||
|
|
|
@ -653,7 +653,7 @@ class AuthComponentTest extends CakeTestCase {
|
|||
|
||||
$this->Controller->request['action'] = 'login';
|
||||
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
|
||||
|
||||
|
||||
$this->Controller->Auth->deny();
|
||||
$this->Controller->Auth->allow(null);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6566,7 +6566,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$this->db->truncate(new Comment());
|
||||
|
||||
$result = $TestModel->saveAll(array(
|
||||
'Article' => array('id' => 2, 'title' => 'I will not save'),
|
||||
'Article' => array('id' => 2, 'title' => 'The title'),
|
||||
'Comment' => array(
|
||||
array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1),
|
||||
array(
|
||||
|
@ -6604,4 +6604,181 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveAllDeepHasManyhasMany method
|
||||
*
|
||||
* return @void
|
||||
*/
|
||||
public function testSaveAllDeepHasManyHasMany() {
|
||||
$this->loadFixtures('Article', 'Comment', 'User', 'Attachment');
|
||||
$TestModel = new Article();
|
||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = array();
|
||||
$TestModel->Comment->unbindModel(array('hasOne' => array('Attachment')), false);
|
||||
$TestModel->Comment->bindModel(array('hasMany' => array('Attachment')), false);
|
||||
|
||||
$this->db->truncate($TestModel);
|
||||
$this->db->truncate(new Comment());
|
||||
$this->db->truncate(new Attachment());
|
||||
|
||||
$result = $TestModel->saveAll(array(
|
||||
'Article' => array('id' => 2, 'title' => 'The title'),
|
||||
'Comment' => array(
|
||||
array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1),
|
||||
array(
|
||||
'comment' => 'hasmany', 'published' => 'Y', 'user_id' => 5,
|
||||
'Attachment' => array(
|
||||
array('attachment' => 'first deep attachment'),
|
||||
array('attachment' => 'second deep attachment'),
|
||||
)
|
||||
)
|
||||
)
|
||||
), array('deep' => true));
|
||||
|
||||
$result = $TestModel->Comment->find('first', array(
|
||||
'conditions' => array('Comment.comment' => 'hasmany'),
|
||||
'fields' => array('id', 'comment', 'published', 'user_id'),
|
||||
'recursive' => -1
|
||||
));
|
||||
$expected = array(
|
||||
'Comment' => array(
|
||||
'id' => 2,
|
||||
'comment' => 'hasmany',
|
||||
'published' => 'Y',
|
||||
'user_id' => 5
|
||||
)
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = $TestModel->Comment->Attachment->find('all', array(
|
||||
'fields' => array('attachment', 'comment_id'),
|
||||
'order' => array('Attachment.id' => 'ASC')
|
||||
));
|
||||
$expected = array(
|
||||
array('Attachment' => array('attachment' => 'first deep attachment', 'comment_id' => 2)),
|
||||
array('Attachment' => array('attachment' => 'second deep attachment', 'comment_id' => 2)),
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveAllDeepOrderHasManyHasMany method
|
||||
*
|
||||
* return @void
|
||||
*/
|
||||
public function testSaveAllDeepOrderHasManyHasMany() {
|
||||
$this->loadFixtures('Article', 'Comment', 'User', 'Attachment');
|
||||
$TestModel = new Article();
|
||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = array();
|
||||
$TestModel->Comment->unbindModel(array('hasOne' => array('Attachment')), false);
|
||||
$TestModel->Comment->bindModel(array('hasMany' => array('Attachment')), false);
|
||||
|
||||
$this->db->truncate($TestModel);
|
||||
$this->db->truncate(new Comment());
|
||||
$this->db->truncate(new Attachment());
|
||||
|
||||
$result = $TestModel->saveAll(array(
|
||||
'Article' => array('id' => 2, 'title' => 'Comment has its data after Attachment'),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'Attachment' => array(
|
||||
array('attachment' => 'attachment should be created with comment_id'),
|
||||
array('attachment' => 'comment should be created with article_id'),
|
||||
),
|
||||
'comment' => 'after associated data',
|
||||
'user_id' => 1
|
||||
)
|
||||
)
|
||||
), array('deep' => true));
|
||||
$result = $TestModel->Comment->find('first', array(
|
||||
'conditions' => array('Comment.article_id' => 2),
|
||||
));
|
||||
|
||||
$this->assertEquals(2, $result['Comment']['article_id']);
|
||||
$this->assertEquals(2, count($result['Attachment']));
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveAllDeepEmptyHasManyHasMany method
|
||||
*
|
||||
* return @void
|
||||
*/
|
||||
public function testSaveAllDeepEmptyHasManyHasMany() {
|
||||
$this->skipIf(!$this->db instanceof Mysql, 'This test is only compatible with Mysql.');
|
||||
$this->loadFixtures('Article', 'Comment', 'User', 'Attachment');
|
||||
$TestModel = new Article();
|
||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = array();
|
||||
$TestModel->Comment->unbindModel(array('hasOne' => array('Attachment')), false);
|
||||
$TestModel->Comment->bindModel(array('hasMany' => array('Attachment')), false);
|
||||
|
||||
$this->db->truncate($TestModel);
|
||||
$this->db->truncate(new Comment());
|
||||
$this->db->truncate(new Attachment());
|
||||
|
||||
$result = $TestModel->saveAll(array(
|
||||
'Article' => array('id' => 3, 'title' => 'Comment has no data'),
|
||||
'Comment' => array(
|
||||
array(
|
||||
'Attachment' => array(
|
||||
array('attachment' => 'attachment should be created with comment_id'),
|
||||
array('attachment' => 'comment should be created with article_id'),
|
||||
),
|
||||
)
|
||||
)
|
||||
), array('deep' => true));
|
||||
$result = $TestModel->Comment->find('first', array(
|
||||
'conditions' => array('Comment.article_id' => 3),
|
||||
));
|
||||
|
||||
$this->assertEquals(3, $result['Comment']['article_id']);
|
||||
$this->assertEquals(2, count($result['Attachment']));
|
||||
}
|
||||
|
||||
/**
|
||||
* testUpdateAllBoolean
|
||||
*
|
||||
* return @void
|
||||
*/
|
||||
public function testUpdateAllBoolean() {
|
||||
$this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio');
|
||||
$TestModel = new Item();
|
||||
$result = $TestModel->updateAll(array('published' => true));
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = $TestModel->find('first', array('fields' => array('id', 'published')));
|
||||
$this->assertEquals(true, $result['Item']['published']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testUpdateAllBooleanConditions
|
||||
*
|
||||
* return @void
|
||||
*/
|
||||
public function testUpdateAllBooleanConditions() {
|
||||
$this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio');
|
||||
$TestModel = new Item();
|
||||
|
||||
$result = $TestModel->updateAll(array('published' => true), array('Item.id' => 1));
|
||||
$this->assertTrue($result);
|
||||
$result = $TestModel->find('first', array(
|
||||
'fields' => array('id', 'published'),
|
||||
'conditions' => array('Item.id' => 1)));
|
||||
$this->assertEquals(true, $result['Item']['published']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testUpdateBoolean
|
||||
*
|
||||
* return @void
|
||||
*/
|
||||
public function testUpdateBoolean() {
|
||||
$this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio');
|
||||
$TestModel = new Item();
|
||||
|
||||
$result = $TestModel->save(array('published' => true, 'id' => 1));
|
||||
$this->assertTrue((boolean)$result);
|
||||
$result = $TestModel->find('first', array(
|
||||
'fields' => array('id', 'published'),
|
||||
'conditions' => array('Item.id' => 1)));
|
||||
$this->assertEquals(true, $result['Item']['published']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@ class FileTest extends CakeTestCase {
|
|||
'filesize' => filesize($file),
|
||||
'mime' => 'text/x-php'
|
||||
);
|
||||
if (!function_exists('finfo_open') && !function_exists('mime_content_type')) {
|
||||
$expecting['mime'] = false;
|
||||
}
|
||||
|
||||
$this->assertEquals($expecting, $result);
|
||||
|
||||
$result = $this->File->ext();
|
||||
|
@ -473,6 +477,7 @@ class FileTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testMime() {
|
||||
$this->skipIf(!function_exists('finfo_open') && !function_exists('mime_content_type'), 'Not able to read mime type');
|
||||
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif';
|
||||
$file = new File($path);
|
||||
$this->assertEquals('image/gif', $file->mime());
|
||||
|
|
|
@ -106,7 +106,6 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertSame(array(), Set::filter(array()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testNumericArrayCheck method
|
||||
*
|
||||
|
@ -196,11 +195,6 @@ class SetTest extends CakeTestCase {
|
|||
$r = Set::merge('foo', 'bar');
|
||||
$this->assertEquals($r, array('foo', 'bar'));
|
||||
|
||||
if (substr(PHP_VERSION, 0, 1) >= 5) {
|
||||
$r = eval('class StaticSetCaller{static function merge($a, $b){return Set::merge($a, $b);}} return StaticSetCaller::merge("foo", "bar");');
|
||||
$this->assertEquals($r, array('foo', 'bar'));
|
||||
}
|
||||
|
||||
$r = Set::merge('foo', array('user' => 'bob', 'no-bar'), 'bar');
|
||||
$this->assertEquals($r, array('foo', 'user' => 'bob', 'no-bar', 'bar'));
|
||||
|
||||
|
@ -236,7 +230,7 @@ class SetTest extends CakeTestCase {
|
|||
$a = array('Tree', 'CounterCache',
|
||||
'Upload' => array('folder' => 'products',
|
||||
'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')));
|
||||
$b = array('Cacheable' => array('enabled' => false),
|
||||
$b = array('Cacheable' => array('enabled' => false),
|
||||
'Limit',
|
||||
'Bindable',
|
||||
'Validator',
|
||||
|
@ -384,14 +378,14 @@ class SetTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testSortString() {
|
||||
$to_sort = array(
|
||||
$toSort = array(
|
||||
'four' => array('number' => 4, 'some' => 'foursome'),
|
||||
'six' => array('number' => 6, 'some' => 'sixsome'),
|
||||
'five' => array('number' => 5, 'some' => 'fivesome'),
|
||||
'two' => array('number' => 2, 'some' => 'twosome'),
|
||||
'three' => array('number' => 3, 'some' => 'threesome')
|
||||
);
|
||||
$sorted = Set::sort($to_sort, '{s}.number', 'asc');
|
||||
$sorted = Set::sort($toSort, '{s}.number', 'asc');
|
||||
$expected = array(
|
||||
'two' => array('number' => 2, 'some' => 'twosome'),
|
||||
'three' => array('number' => 3, 'some' => 'threesome'),
|
||||
|
@ -1044,7 +1038,7 @@ class SetTest extends CakeTestCase {
|
|||
array('A2', 'B2')
|
||||
);
|
||||
$expected = array('A1', 'A2');
|
||||
$result = Set::extract('/0', $data);
|
||||
$result = Set::extract('/0', $data);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
|
@ -1431,7 +1425,7 @@ class SetTest extends CakeTestCase {
|
|||
),
|
||||
'Comment' => array(
|
||||
'keep' => array(
|
||||
'Attachment' => array(
|
||||
'Attachment' => array(
|
||||
'fields' => array(
|
||||
0 => 'attachment',
|
||||
),
|
||||
|
@ -1443,7 +1437,7 @@ class SetTest extends CakeTestCase {
|
|||
),
|
||||
'Article' => array(
|
||||
'keep' => array(
|
||||
'Comment' => array(
|
||||
'Comment' => array(
|
||||
'fields' => array(
|
||||
0 => 'comment',
|
||||
1 => 'published',
|
||||
|
@ -1461,8 +1455,6 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertTrue(Set::matches('/Article/keep/Comment', $r));
|
||||
$this->assertEquals(Set::extract('/Article/keep/Comment/fields', $r), array('comment', 'published'));
|
||||
$this->assertEquals(Set::extract('/Article/keep/User/fields', $r), array('user'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1471,7 +1463,6 @@ class SetTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testSetExtractReturnsEmptyArray() {
|
||||
|
||||
$this->assertEquals(Set::extract(array(), '/Post/id'), array());
|
||||
|
||||
$this->assertEquals(Set::extract('/Post/id', array()), array());
|
||||
|
@ -1482,7 +1473,6 @@ class SetTest extends CakeTestCase {
|
|||
)), array());
|
||||
|
||||
$this->assertEquals(Set::extract(array(), 'Message.flash'), null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1833,7 +1823,6 @@ class SetTest extends CakeTestCase {
|
|||
$result = Set::diff($a, $b);
|
||||
$this->assertEquals($result, $b);
|
||||
|
||||
|
||||
$a = array('name' => 'bob', 'address' => 'home');
|
||||
$b = array();
|
||||
$result = Set::diff($a, $b);
|
||||
|
@ -2201,6 +2190,7 @@ class SetTest extends CakeTestCase {
|
|||
array('id' => 1, 'article_id' => 1, 'user_id' => 1, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'),
|
||||
array('id' => 2, 'article_id' => 1, 'user_id' => 2, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'))));
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$class = new stdClass;
|
||||
$class->User = new stdClass;
|
||||
$class->User->psword = 'whatever';
|
||||
|
@ -2226,7 +2216,8 @@ class SetTest extends CakeTestCase {
|
|||
$comment2->published = 'Y';
|
||||
$comment2->created = '2007-03-18 10:47:23';
|
||||
$comment2->updated = '2007-03-18 10:49:31';
|
||||
$class->User->Comment = array($comment, $comment2);
|
||||
// @codingStandardsIgnoreEnd
|
||||
$class->User->Comment = array($comment, $comment2);
|
||||
$result = Set::reverse($class);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
@ -2238,9 +2229,14 @@ class SetTest extends CakeTestCase {
|
|||
$class->Profile->name = 'Joe Mamma';
|
||||
|
||||
$result = Set::reverse($class);
|
||||
$expected = array('User' => array('id' => '100'), 'someString' => 'this is some string', 'Profile' => array('name' => 'Joe Mamma'));
|
||||
$expected = array(
|
||||
'User' => array('id' => '100'),
|
||||
'someString' => 'this is some string',
|
||||
'Profile' => array('name' => 'Joe Mamma')
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$class = new stdClass;
|
||||
$class->User = new stdClass;
|
||||
$class->User->id = 100;
|
||||
|
@ -2248,6 +2244,7 @@ class SetTest extends CakeTestCase {
|
|||
$class->Profile = new stdClass;
|
||||
$class->Profile->name = 'Joe Mamma';
|
||||
$class->Profile->_name_ = 'Profile';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
$result = Set::reverse($class);
|
||||
$expected = array('User' => array('id' => '100'), 'Profile' => array('name' => 'Joe Mamma'));
|
||||
|
@ -2476,6 +2473,7 @@ class SetTest extends CakeTestCase {
|
|||
);
|
||||
$mapped = Set::map($data);
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$expected = new stdClass();
|
||||
$expected->_name_ = 'IndexedPage';
|
||||
$expected->id = 2;
|
||||
|
@ -2485,6 +2483,7 @@ class SetTest extends CakeTestCase {
|
|||
$expected->redirect = '';
|
||||
$expected->created = "1195055503";
|
||||
$expected->updated = "1195055503";
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->assertEquals($mapped[1], $expected);
|
||||
|
||||
$ids = array();
|
||||
|
@ -2516,6 +2515,7 @@ class SetTest extends CakeTestCase {
|
|||
)
|
||||
));
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$expected = new stdClass;
|
||||
$expected->_name_ = 'Post';
|
||||
$expected->id = '1';
|
||||
|
@ -2553,6 +2553,7 @@ class SetTest extends CakeTestCase {
|
|||
$expected2->Author->updated = "2007-03-17 01:22:31";
|
||||
$expected2->Author->test = "working";
|
||||
$expected2->Author->_name_ = 'Author';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
$test = array();
|
||||
$test[0] = $expected;
|
||||
|
@ -2561,11 +2562,12 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertEquals($test, $result);
|
||||
|
||||
$result = Set::map(
|
||||
array(
|
||||
'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
|
||||
'Author' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'),
|
||||
)
|
||||
);
|
||||
array(
|
||||
'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
|
||||
'Author' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'),
|
||||
)
|
||||
);
|
||||
// @codingStandardsIgnoreStart
|
||||
$expected = new stdClass;
|
||||
$expected->_name_ = 'Post';
|
||||
$expected->id = '1';
|
||||
|
@ -2584,6 +2586,7 @@ class SetTest extends CakeTestCase {
|
|||
$expected->Author->updated = "2007-03-17 01:18:31";
|
||||
$expected->Author->test = "working";
|
||||
$expected->Author->_name_ = 'Author';
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
//Case where extra HABTM fields come back in a result
|
||||
|
@ -2624,6 +2627,7 @@ class SetTest extends CakeTestCase {
|
|||
|
||||
$result = Set::map($data);
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$expected = new stdClass();
|
||||
$expected->_name_ = 'User';
|
||||
$expected->id = 1;
|
||||
|
@ -2646,7 +2650,6 @@ class SetTest extends CakeTestCase {
|
|||
|
||||
$piece->_name_ = 'Piece';
|
||||
|
||||
|
||||
$piece2 = new stdClass();
|
||||
$piece2->id = 2;
|
||||
$piece2->title = 'Moonlight Sonata 2';
|
||||
|
@ -2661,6 +2664,7 @@ class SetTest extends CakeTestCase {
|
|||
$piece2->PiecesUser->_name_ = 'PiecesUser';
|
||||
|
||||
$piece2->_name_ = 'Piece';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
$expected->Piece = array($piece, $piece2);
|
||||
|
||||
|
@ -2709,6 +2713,7 @@ class SetTest extends CakeTestCase {
|
|||
|
||||
$result = Set::map($data);
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
$expected = new stdClass();
|
||||
$expected->_name_ = 'FooUser';
|
||||
$expected->id = 1;
|
||||
|
@ -2741,6 +2746,7 @@ class SetTest extends CakeTestCase {
|
|||
$piece2->PiecesUser->piece_id = 2;
|
||||
$piece2->PiecesUser->user_id = 2;
|
||||
$piece2->PiecesUser->_name_ = 'FooPiecesUser';
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
$expected->Piece = array($piece, $piece2);
|
||||
|
||||
|
@ -2766,7 +2772,6 @@ class SetTest extends CakeTestCase {
|
|||
$expected = array('ModelOne' => array('id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2', 'field_three' => 'a3.m1.f3'));
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
||||
$array1 = array(
|
||||
0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2')),
|
||||
1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2')));
|
||||
|
@ -2790,7 +2795,7 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertEquals($result, $array1);
|
||||
|
||||
$result = Set::pushDiff($array1, $array2);
|
||||
$this->assertEquals($result, $array1+$array2);
|
||||
$this->assertEquals($result, $array1 + $array2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2809,7 +2814,6 @@ class SetTest extends CakeTestCase {
|
|||
$expected = 9;
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
||||
$result = Set::apply('/Movie/rating', $data, 'array_product');
|
||||
$expected = 15;
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -2822,14 +2826,13 @@ class SetTest extends CakeTestCase {
|
|||
$expected = array('MOVIE 3', 'MOVIE 1', 'MOVIE 2');
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = Set::apply('/Movie/rating', $data, array('SetTest', '_method'), array('type' => 'reduce'));
|
||||
$result = Set::apply('/Movie/rating', $data, array('SetTest', 'method'), array('type' => 'reduce'));
|
||||
$expected = 9;
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = Set::apply('/Movie/rating', $data, 'strtoupper', array('type' => 'non existing type'));
|
||||
$expected = null;
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2837,7 +2840,7 @@ class SetTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
static function _method($val1, $val2) {
|
||||
public static function method($val1, $val2) {
|
||||
$val1 += $val2;
|
||||
return $val1;
|
||||
}
|
||||
|
@ -2905,7 +2908,7 @@ class SetTest extends CakeTestCase {
|
|||
)
|
||||
));
|
||||
$this->assertEquals($expected, $result);
|
||||
$string ='<data><post title="Title of this post" description="cool"/></data>';
|
||||
$string = '<data><post title="Title of this post" description="cool"/></data>';
|
||||
|
||||
$xml = Xml::build($string);
|
||||
$result = Set::reverse($xml);
|
||||
|
@ -3629,7 +3632,7 @@ class SetTest extends CakeTestCase {
|
|||
);
|
||||
|
||||
$result = Set::nest($input, array('idPath' => '/id', 'parentPath' => '/parent_id'));
|
||||
foreach($result as &$row) {
|
||||
foreach ($result as &$row) {
|
||||
if (empty($row['children'])) {
|
||||
unset($row['children']);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class JqueryEngineHelperTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = $this->Jquery->event('click', '$(this).hide();');
|
||||
$expected = '$("#myLink").bind("click", function (event) {$(this).hide();'."\n".'return false;});';
|
||||
$expected = '$("#myLink").bind("click", function (event) {$(this).hide();' . "\n" . 'return false;});';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,19 +177,6 @@ class TestView extends View {
|
|||
return $this->_paths($plugin, $cached);
|
||||
}
|
||||
|
||||
/**
|
||||
* _render wrapper for testing (temporary).
|
||||
*
|
||||
* @param string $___viewFn
|
||||
* @param string $___dataForView
|
||||
* @param string $loadHelpers
|
||||
* @param string $cached
|
||||
* @return void
|
||||
*/
|
||||
public function render_($___viewFn, $___dataForView, $loadHelpers = true, $cached = false) {
|
||||
return $this->_render($___viewFn, $___dataForView, $loadHelpers, $cached);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test only function to return instance scripts.
|
||||
*
|
||||
|
@ -774,7 +761,7 @@ class ViewTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test__get() {
|
||||
public function testMagicGet() {
|
||||
$View = new View($this->PostsController);
|
||||
$View->loadHelper('Html');
|
||||
$this->assertInstanceOf('HtmlHelper', $View->Html);
|
||||
|
|
|
@ -58,7 +58,7 @@ class PagesController extends AppController {
|
|||
if (!$count) {
|
||||
$this->redirect('/');
|
||||
}
|
||||
$page = $subpage = $title_for_layout = null;
|
||||
$page = $subpage = $titleForLayout = null;
|
||||
|
||||
if (!empty($path[0])) {
|
||||
$page = $path[0];
|
||||
|
@ -67,9 +67,14 @@ class PagesController extends AppController {
|
|||
$subpage = $path[1];
|
||||
}
|
||||
if (!empty($path[$count - 1])) {
|
||||
$title_for_layout = Inflector::humanize($path[$count - 1]);
|
||||
$titleForLayout = Inflector::humanize($path[$count - 1]);
|
||||
}
|
||||
$this->set(compact('page', 'subpage', 'title_for_layout'));
|
||||
$this->set(array(
|
||||
'page' => $page,
|
||||
'subpage' => $subpage,
|
||||
'title_for_layout' => $titleForLayout
|
||||
));
|
||||
$this->render(implode('/', $path));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue