Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -2,20 +2,20 @@
/**
* ModelDeleteTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
require_once dirname(__FILE__) . DS . 'ModelTestBase.php';
/**
@ -149,7 +149,7 @@ class ModelDeleteTest extends BaseModelTest {
* @return void
*/
public function testDeleteDependentWithConditions() {
$this->loadFixtures('Cd','Book','OverallFavorite');
$this->loadFixtures('Cd', 'Book', 'OverallFavorite');
$Cd = new Cd();
$Book = new Book();
@ -421,6 +421,20 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
}
/**
* testDeleteAll diamond operator method
*
* @return void
*/
public function testDeleteAllDiamondOperator() {
$this->loadFixtures('Article');
$article = new Article();
$result = $article->deleteAll(array('Article.id <>' => 1));
$this->assertTrue($result);
$this->assertFalse($article->exists(2));
}
/**
* testDeleteAllUnknownColumn method
*
@ -434,6 +448,88 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertFalse($result, 'deleteAll returned true when find query generated sql error. %s');
}
/**
* testDeleteAllFailedFind method
*
* Eg: Behavior callback stops the event, find returns null
*
* @return void
*/
public function testDeleteAllFailedFind() {
$this->loadFixtures('Article');
$TestModel = $this->getMock('Article', array('find'));
$TestModel->expects($this->once())
->method('find')
->will($this->returnValue(null));
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertFalse($result);
}
/**
* testDeleteAllMultipleRowsPerId method
*
* Ensure find done in deleteAll only returns distinct ids. A wacky combination
* of association and conditions can sometimes generate multiple rows per id.
*
* @return void
*/
public function testDeleteAllMultipleRowsPerId() {
$this->loadFixtures('Article', 'User');
$TestModel = new Article();
$TestModel->unbindModel(array(
'belongsTo' => array('User'),
'hasMany' => array('Comment'),
'hasAndBelongsToMany' => array('Tag')
), false);
$TestModel->bindModel(array(
'belongsTo' => array(
'User' => array(
'foreignKey' => false,
'conditions' => array(
'Article.user_id = 1'
)
)
)
), false);
$result = $TestModel->deleteAll(
array('Article.user_id' => array(1, 3)),
true,
true
);
$this->assertTrue($result);
}
/**
* testDeleteAllWithOrderProperty
*
* Ensure find done in deleteAll works with models that has $order property set
*
* @return void
*/
public function testDeleteAllWithOrderProperty() {
$this->loadFixtures('Article', 'User');
$TestModel = new Article();
$TestModel->order = 'Article.published desc';
$TestModel->unbindModel(array(
'belongsTo' => array('User'),
'hasMany' => array('Comment'),
'hasAndBelongsToMany' => array('Tag')
), false);
$result = $TestModel->deleteAll(
array('Article.user_id' => array(1, 3)),
true,
true
);
$this->assertTrue($result);
}
/**
* testRecursiveDel method
*
@ -548,6 +644,7 @@ class ModelDeleteTest extends BaseModelTest {
'Tag' => array('with' => 'TestPlugin.ArticlesTag')
)), false);
$Article->ArticlesTag->order = null;
$this->assertTrue($Article->delete(1));
}
@ -638,7 +735,7 @@ class ModelDeleteTest extends BaseModelTest {
$this->assertEquals(4, $result);
$result = $Article->delete(1, true);
$this->assertSame($result, true);
$this->assertTrue($result);
$result = $Article->Comment->find('count', array(
'conditions' => array('Comment.article_id' => 1)