mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 16:23:59 +01:00 
			
		
		
		
	Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
		
							parent
							
								
									5a580df460
								
							
						
					
					
						commit
						235a541597
					
				
					 793 changed files with 60746 additions and 23753 deletions
				
			
		|  | @ -1,19 +1,21 @@ | |||
| <?php | ||||
| /** | ||||
|  * 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 | ||||
|  * @since         CakePHP(tm) v 1.2.0.5669 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Model', 'Model'); | ||||
| App::uses('AppModel', 'Model'); | ||||
| 
 | ||||
| require_once dirname(dirname(__FILE__)) . DS . 'models.php'; | ||||
| 
 | ||||
| /** | ||||
|  | @ -26,7 +28,7 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| /** | ||||
|  * autoFixtures property | ||||
|  * | ||||
|  * @var bool false | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $autoFixtures = false; | ||||
| 
 | ||||
|  | @ -68,13 +70,13 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->loadFixtures('TranslateTable', 'Tag', 'TranslatedItem', 'Translate', 'User', 'TranslatedArticle', 'TranslateArticle'); | ||||
| 		$TestModel = new Tag(); | ||||
| 		$TestModel->translateTable = 'another_i18n'; | ||||
| 		$TestModel->Behaviors->attach('Translate', array('title')); | ||||
| 		$TestModel->Behaviors->load('Translate', array('title')); | ||||
| 		$translateModel = $TestModel->Behaviors->Translate->translateModel($TestModel); | ||||
| 		$this->assertEquals('I18nModel', $translateModel->name); | ||||
| 		$this->assertEquals('another_i18n', $translateModel->useTable); | ||||
| 
 | ||||
| 		$TestModel = new User(); | ||||
| 		$TestModel->Behaviors->attach('Translate', array('title')); | ||||
| 		$TestModel->Behaviors->load('Translate', array('title')); | ||||
| 		$translateModel = $TestModel->Behaviors->Translate->translateModel($TestModel); | ||||
| 		$this->assertEquals('I18nModel', $translateModel->name); | ||||
| 		$this->assertEquals('i18n', $translateModel->useTable); | ||||
|  | @ -230,6 +232,32 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $TestModel->field('title', array('TranslatedItem.id' => 1)); | ||||
| 		$expected = 'Title #1'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $TestModel->read('title', 1); | ||||
| 		$expected = array( | ||||
| 			'TranslatedItem' => array( | ||||
| 				'id' => 1, | ||||
| 				'slug' => 'first_translated', | ||||
| 				'locale' => 'eng', | ||||
| 				'title' => 'Title #1', | ||||
| 				'translated_article_id' => 1, | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $TestModel->read('id, title', 1); | ||||
| 		$expected = array( | ||||
| 			'TranslatedItem' => array( | ||||
| 				'id' => 1, | ||||
| 				'locale' => 'eng', | ||||
| 				'title' => 'Title #1', | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -273,6 +301,40 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testLocaleSingleCountWithConditions method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testLocaleSingleCountWithConditions() { | ||||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$TestModel = new TranslatedItem(); | ||||
| 		$TestModel->locale = 'eng'; | ||||
| 		$result = $TestModel->find('all', array( | ||||
| 			'conditions' => array('slug' => 'first_translated') | ||||
| 		)); | ||||
| 		$expected = array( | ||||
| 			array( | ||||
| 				'TranslatedItem' => array( | ||||
| 					'id' => 1, | ||||
| 					'slug' => 'first_translated', | ||||
| 					'locale' => 'eng', | ||||
| 					'title' => 'Title #1', | ||||
| 					'content' => 'Content #1', | ||||
| 					'translated_article_id' => 1, | ||||
| 				) | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $TestModel->find('count', array( | ||||
| 			'conditions' => array('slug' => 'first_translated') | ||||
| 		)); | ||||
| 		$expected = 1; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testLocaleSingleAssociations method | ||||
|  * | ||||
|  | @ -352,6 +414,33 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test loading fields with 0 as the translated value. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFetchTranslationsWithZero() { | ||||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$model = new TranslatedItem(); | ||||
| 		$translateModel = $model->translateModel(); | ||||
| 		$translateModel->updateAll(array('content' => "'0'")); | ||||
| 		$model->locale = 'eng'; | ||||
| 
 | ||||
| 		$result = $model->read(null, 1); | ||||
| 		$expected = array( | ||||
| 			'TranslatedItem' => array( | ||||
| 				'id' => 1, | ||||
| 				'slug' => 'first_translated', | ||||
| 				'locale' => 'eng', | ||||
| 				'title' => '0', | ||||
| 				'content' => '0', | ||||
| 				'translated_article_id' => 1, | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testLocaleMultiple method | ||||
|  * | ||||
|  | @ -530,6 +619,36 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test saving/deleting with an alias, uses the model name. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSaveDeleteIgnoreAlias() { | ||||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$TestModel = new TranslatedItem(array('alias' => 'SomethingElse')); | ||||
| 		$TestModel->locale = 'spa'; | ||||
| 		$data = array( | ||||
| 			'slug' => 'fourth_translated', | ||||
| 			'title' => 'Leyenda #4', | ||||
| 			'content' => 'Contenido #4', | ||||
| 			'translated_article_id' => 1, | ||||
| 		); | ||||
| 		$TestModel->create($data); | ||||
| 		$TestModel->save(); | ||||
| 		$id = $TestModel->id; | ||||
| 		$result = $TestModel->read(); | ||||
| 		$expected = array($TestModel->alias => array_merge($data, array('id' => $id, 'locale' => 'spa'))); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$TestModel->delete($id); | ||||
| 		$result = $TestModel->translateModel()->find('count', array( | ||||
| 			'conditions' => array('foreign_key' => $id) | ||||
| 		)); | ||||
| 		$this->assertEquals(0, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test save multiple locales method | ||||
|  * | ||||
|  | @ -600,6 +719,54 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->assertCount(2, $result['Content']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testSaveAssociatedAtomic method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSaveAssociatedAtomic() { | ||||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$TestModel = new TranslatedItem(); | ||||
| 		$data = array( | ||||
| 			'slug' => 'fourth_translated', | ||||
| 			'title' => array( | ||||
| 				'eng' => 'Title #4' | ||||
| 			), | ||||
| 			'content' => array( | ||||
| 				'eng' => 'Content #4' | ||||
| 			), | ||||
| 			'translated_article_id' => 1, | ||||
| 		); | ||||
| 		$Mock = $this->getMockForModel('TranslateTestModel', array('save')); | ||||
| 		$TestModel->Behaviors->Translate->runtime[$TestModel->alias]['model'] = $Mock; | ||||
| 
 | ||||
| 		$with = array( | ||||
| 			'TranslateTestModel' => array ( | ||||
| 				'model' => 'TranslatedItem', | ||||
| 				'foreign_key' => '4', | ||||
| 				'field' => 'content', | ||||
| 				'locale' => 'eng', | ||||
| 				'content' => 'Content #4', | ||||
| 			) | ||||
| 		); | ||||
| 		$Mock->expects($this->at(0))->method('save')->with($with, array('atomic' => false)); | ||||
| 
 | ||||
| 		$with = array( | ||||
| 			'TranslateTestModel' => array ( | ||||
| 				'model' => 'TranslatedItem', | ||||
| 				'foreign_key' => '4', | ||||
| 				'field' => 'title', | ||||
| 				'locale' => 'eng', | ||||
| 				'content' => 'Title #4', | ||||
| 			) | ||||
| 		); | ||||
| 		$Mock->expects($this->at(1))->method('save')->with($with, array('atomic' => false)); | ||||
| 
 | ||||
| 		$TestModel->create(); | ||||
| 		$TestModel->saveAssociated($data, array('atomic' => false)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that saving only some of the translated fields allows the record to be found again. | ||||
|  * | ||||
|  | @ -628,6 +795,76 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that all fields are create with partial data + multiple locales. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSavePartialFieldMultipleLocales() { | ||||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$TestModel = new TranslatedItem(); | ||||
| 		$TestModel->locale = 'eng'; | ||||
| 		$data = array( | ||||
| 			'slug' => 'fifth_translated', | ||||
| 			'title' => array('eng' => 'Title #5', 'spa' => 'Leyenda #5'), | ||||
| 		); | ||||
| 		$TestModel->create($data); | ||||
| 		$TestModel->save(); | ||||
| 		$TestModel->unbindTranslation(); | ||||
| 
 | ||||
| 		$translations = array('title' => 'Title', 'content' => 'Content'); | ||||
| 		$TestModel->bindTranslation($translations, false); | ||||
| 		$result = $TestModel->read(null, $TestModel->id); | ||||
| 		$expected = array( | ||||
| 			'TranslatedItem' => array( | ||||
| 				'id' => '4', | ||||
| 				'translated_article_id' => null, | ||||
| 				'slug' => 'fifth_translated', | ||||
| 				'locale' => 'eng', | ||||
| 				'title' => 'Title #5', | ||||
| 				'content' => '' | ||||
| 			), | ||||
| 			'Title' => array( | ||||
| 				0 => array( | ||||
| 					'id' => '19', | ||||
| 					'locale' => 'eng', | ||||
| 					'model' => 'TranslatedItem', | ||||
| 					'foreign_key' => '4', | ||||
| 					'field' => 'title', | ||||
| 					'content' => 'Title #5' | ||||
| 				), | ||||
| 				1 => array( | ||||
| 					'id' => '20', | ||||
| 					'locale' => 'spa', | ||||
| 					'model' => 'TranslatedItem', | ||||
| 					'foreign_key' => '4', | ||||
| 					'field' => 'title', | ||||
| 					'content' => 'Leyenda #5' | ||||
| 				) | ||||
| 			), | ||||
| 			'Content' => array( | ||||
| 				0 => array( | ||||
| 					'id' => '21', | ||||
| 					'locale' => 'eng', | ||||
| 					'model' => 'TranslatedItem', | ||||
| 					'foreign_key' => '4', | ||||
| 					'field' => 'content', | ||||
| 					'content' => '' | ||||
| 				), | ||||
| 				1 => array( | ||||
| 					'id' => '22', | ||||
| 					'locale' => 'spa', | ||||
| 					'model' => 'TranslatedItem', | ||||
| 					'foreign_key' => '4', | ||||
| 					'field' => 'content', | ||||
| 					'content' => '' | ||||
| 				) | ||||
| 			) | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testSaveUpdate method | ||||
|  * | ||||
|  | @ -705,7 +942,7 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 
 | ||||
| 		$TestModel = new TranslatedItem(); | ||||
| 		$TestModel->locale = 'eng'; | ||||
| 		$TestModel->validate['title'] = 'notEmpty'; | ||||
| 		$TestModel->validate['title'] = 'notBlank'; | ||||
| 		$data = array('TranslatedItem' => array( | ||||
| 			'id' => 1, | ||||
| 			'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'), | ||||
|  | @ -841,6 +1078,7 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testValidation() { | ||||
| 		Configure::write('Config.language', 'eng'); | ||||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$TestModel = new TranslatedItem(); | ||||
|  | @ -869,6 +1107,29 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->assertFalse(empty($result)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test restoring fields after temporary binds method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFieldsRestoreAfterBind() { | ||||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$TestModel = new TranslatedItem(); | ||||
| 
 | ||||
| 		$translations = array('title' => 'Title'); | ||||
| 		$TestModel->bindTranslation($translations); | ||||
| 
 | ||||
| 		$result = $TestModel->find('first'); | ||||
| 		$this->assertArrayHasKey('Title', $result); | ||||
| 		$this->assertArrayHasKey('content', $result['Title'][0]); | ||||
| 		$this->assertArrayNotHasKey('title', $result); | ||||
| 
 | ||||
| 		$result = $TestModel->find('first'); | ||||
| 		$this->assertArrayNotHasKey('Title', $result); | ||||
| 		$this->assertEquals('Title #1', $result['TranslatedItem']['title']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testAttachDetach method | ||||
|  * | ||||
|  | @ -887,7 +1148,7 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$expected = array('Title', 'Content'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$TestModel->Behaviors->detach('Translate'); | ||||
| 		$TestModel->Behaviors->unload('Translate'); | ||||
| 		$result = array_keys($TestModel->hasMany); | ||||
| 		$expected = array(); | ||||
| 		$this->assertEquals($expected, $result); | ||||
|  | @ -901,7 +1162,7 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$result = isset($Behavior->runtime[$TestModel->alias]); | ||||
| 		$this->assertFalse($result); | ||||
| 
 | ||||
| 		$TestModel->Behaviors->attach('Translate', array('title' => 'Title', 'content' => 'Content')); | ||||
| 		$TestModel->Behaviors->load('Translate', array('title' => 'Title', 'content' => 'Content')); | ||||
| 		$result = array_keys($TestModel->hasMany); | ||||
| 		$expected = array('Title', 'Content'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
|  | @ -1083,9 +1344,9 @@ class TranslateBehaviorTest extends CakeTestCase { | |||
| 		$this->loadFixtures('Translate', 'TranslatedItem'); | ||||
| 
 | ||||
| 		$TestModel = new TranslatedItem(); | ||||
| 		$TestModel->Behaviors->detach('Translate'); | ||||
| 		$TestModel->Behaviors->unload('Translate'); | ||||
| 		$TestModel->actsAs = array(); | ||||
| 		$TestModel->Behaviors->attach('Translate'); | ||||
| 		$TestModel->Behaviors->load('Translate'); | ||||
| 		$TestModel->bindTranslation(array('title', 'content'), true); | ||||
| 		$result = $TestModel->unbindTranslation(); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko