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
				
			
		|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * ControllerTask Test Case | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||||
|  * 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://cakephp.org CakePHP(tm) Project | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @since         CakePHP(tm) v 1.3 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('ConsoleOutput', 'Console'); | ||||
|  | @ -39,10 +38,11 @@ $imported = class_exists('BakeArticle') || class_exists('BakeComment') || class_ | |||
| if (!$imported) { | ||||
| 	define('ARTICLE_MODEL_CREATED', true); | ||||
| 
 | ||||
| /** | ||||
|  * BakeArticle | ||||
|  */ | ||||
| 	class BakeArticle extends Model { | ||||
| 
 | ||||
| 		public $name = 'BakeArticle'; | ||||
| 
 | ||||
| 		public $hasMany = array('BakeComment'); | ||||
| 
 | ||||
| 		public $hasAndBelongsToMany = array('BakeTag'); | ||||
|  | @ -90,6 +90,10 @@ class ControllerTaskTest extends CakeTestCase { | |||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 		$this->Task->Test = $this->getMock('TestTask', array(), array($out, $out, $in)); | ||||
| 
 | ||||
| 		if (!defined('ARTICLE_MODEL_CREATED')) { | ||||
| 			$this->markTestSkipped('Could not run as an Article, Tag or Comment model was already loaded.'); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -191,9 +195,9 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testDoHelpersTrailingSpace() { | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Javascript, Ajax, CustomOne  ')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Text, Number, CustomOne  ')); | ||||
| 		$result = $this->Task->doHelpers(); | ||||
| 		$expected = array('Javascript', 'Ajax', 'CustomOne'); | ||||
| 		$expected = array('Text', 'Number', 'CustomOne'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -204,9 +208,9 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testDoHelpersTrailingCommas() { | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Javascript, Ajax, CustomOne, , ')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Text, Number, CustomOne, , ')); | ||||
| 		$result = $this->Task->doHelpers(); | ||||
| 		$expected = array('Javascript', 'Ajax', 'CustomOne'); | ||||
| 		$expected = array('Text', 'Number', 'CustomOne'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -218,7 +222,7 @@ class ControllerTaskTest extends CakeTestCase { | |||
| 	public function testDoComponentsNo() { | ||||
| 		$this->Task->expects($this->any())->method('in')->will($this->returnValue('n')); | ||||
| 		$result = $this->Task->doComponents(); | ||||
| 		$this->assertSame(array(), $result); | ||||
| 		$this->assertSame(array('Paginator'), $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -231,7 +235,7 @@ class ControllerTaskTest extends CakeTestCase { | |||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security  ')); | ||||
| 
 | ||||
| 		$result = $this->Task->doComponents(); | ||||
| 		$expected = array('RequestHandler', 'Security'); | ||||
| 		$expected = array('Paginator', 'RequestHandler', 'Security'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -245,7 +249,7 @@ class ControllerTaskTest extends CakeTestCase { | |||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , ')); | ||||
| 
 | ||||
| 		$result = $this->Task->doComponents(); | ||||
| 		$expected = array('RequestHandler', 'Security'); | ||||
| 		$expected = array('Paginator', 'RequestHandler', 'Security'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -257,11 +261,11 @@ class ControllerTaskTest extends CakeTestCase { | |||
| 	public function testConfirmController() { | ||||
| 		$controller = 'Posts'; | ||||
| 		$scaffold = false; | ||||
| 		$helpers = array('Ajax', 'Time'); | ||||
| 		$helpers = array('Js', 'Time'); | ||||
| 		$components = array('Acl', 'Auth'); | ||||
| 
 | ||||
| 		$this->Task->expects($this->at(4))->method('out')->with("Controller Name:\n\t$controller"); | ||||
| 		$this->Task->expects($this->at(5))->method('out')->with("Helpers:\n\tAjax, Time"); | ||||
| 		$this->Task->expects($this->at(5))->method('out')->with("Helpers:\n\tJs, Time"); | ||||
| 		$this->Task->expects($this->at(6))->method('out')->with("Components:\n\tAcl, Auth"); | ||||
| 		$this->Task->confirmController($controller, $scaffold, $helpers, $components); | ||||
| 	} | ||||
|  | @ -272,32 +276,21 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testBake() { | ||||
| 		$helpers = array('Ajax', 'Time'); | ||||
| 		$helpers = array('Js', 'Time'); | ||||
| 		$components = array('Acl', 'Auth'); | ||||
| 		$this->Task->expects($this->any())->method('createFile')->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$result = $this->Task->bake('Articles', '--actions--', $helpers, $components); | ||||
| 		$this->assertContains(' * @property Article $Article', $result); | ||||
| 		$this->assertContains(' * @property AclComponent $Acl', $result); | ||||
| 		$this->assertContains(' * @property AuthComponent $Auth', $result); | ||||
| 		$this->assertContains('class ArticlesController extends AppController', $result); | ||||
| 		$this->assertContains("public \$components = array('Acl', 'Auth')", $result); | ||||
| 		$this->assertContains("public \$helpers = array('Ajax', 'Time')", $result); | ||||
| 		$this->assertContains("--actions--", $result); | ||||
| 		$result = $this->Task->bake('Articles', null, $helpers, $components); | ||||
| 		$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoActions.ctp'); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->Task->bake('Articles', null, array(), array()); | ||||
| 		$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoHelpersOrComponents.ctp'); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->Task->bake('Articles', 'scaffold', $helpers, $components); | ||||
| 		$this->assertContains("class ArticlesController extends AppController", $result); | ||||
| 		$this->assertContains("public \$scaffold", $result); | ||||
| 		$this->assertNotContains('@property', $result); | ||||
| 		$this->assertNotContains('helpers', $result); | ||||
| 		$this->assertNotContains('components', $result); | ||||
| 
 | ||||
| 		$result = $this->Task->bake('Articles', '--actions--', array(), array()); | ||||
| 		$this->assertContains('class ArticlesController extends AppController', $result); | ||||
| 		$this->assertSame(substr_count($result, '@property'), 1); | ||||
| 		$this->assertNotContains('components', $result); | ||||
| 		$this->assertNotContains('helpers', $result); | ||||
| 		$this->assertContains('--actions--', $result); | ||||
| 		$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'Scaffold.ctp'); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -340,32 +333,11 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testBakeActionsUsingSessions() { | ||||
| 		$this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Testing bakeActions requires Article, Comment & Tag Model to be undefined.'); | ||||
| 
 | ||||
| 		$result = $this->Task->bakeActions('BakeArticles', null, true); | ||||
| 
 | ||||
| 		$this->assertContains('function index() {', $result); | ||||
| 		$this->assertContains('$this->BakeArticle->recursive = 0;', $result); | ||||
| 		$this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function view($id = null)', $result); | ||||
| 		$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); | ||||
| 		$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->read(null, \$id)", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function add()', $result); | ||||
| 		$this->assertContains("if (\$this->request->is('post'))", $result); | ||||
| 		$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result); | ||||
| 		$this->assertContains("\$this->Session->setFlash(__('The bake article has been saved'));", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function edit($id = null)', $result); | ||||
| 		$this->assertContains("\$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function delete($id = null)', $result); | ||||
| 		$this->assertContains('if ($this->BakeArticle->delete())', $result); | ||||
| 		$this->assertContains("\$this->Session->setFlash(__('Bake article deleted'));", $result); | ||||
| 		$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'ActionsUsingSessions.ctp'); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->Task->bakeActions('BakeArticles', 'admin_', true); | ||||
| 
 | ||||
| 		$this->assertContains('function admin_index() {', $result); | ||||
| 		$this->assertContains('function admin_add()', $result); | ||||
| 		$this->assertContains('function admin_view($id = null)', $result); | ||||
|  | @ -379,31 +351,9 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testBakeActionsWithNoSessions() { | ||||
| 		$this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Testing bakeActions requires Article, Tag, Comment Models to be undefined.'); | ||||
| 
 | ||||
| 		$result = $this->Task->bakeActions('BakeArticles', null, false); | ||||
| 
 | ||||
| 		$this->assertContains('function index() {', $result); | ||||
| 		$this->assertContains('$this->BakeArticle->recursive = 0;', $result); | ||||
| 		$this->assertContains("\$this->set('bakeArticles', \$this->paginate());", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function view($id = null)', $result); | ||||
| 		$this->assertContains("throw new NotFoundException(__('Invalid bake article'));", $result); | ||||
| 		$this->assertContains("\$this->set('bakeArticle', \$this->BakeArticle->read(null, \$id)", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function add()', $result); | ||||
| 		$this->assertContains("if (\$this->request->is('post'))", $result); | ||||
| 		$this->assertContains('if ($this->BakeArticle->save($this->request->data))', $result); | ||||
| 
 | ||||
| 		$this->assertContains("\$this->flash(__('The bake article has been saved.'), array('action' => 'index'))", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function edit($id = null)', $result); | ||||
| 		$this->assertContains("\$this->BakeArticle->BakeTag->find('list')", $result); | ||||
| 		$this->assertContains("\$this->set(compact('bakeTags'))", $result); | ||||
| 
 | ||||
| 		$this->assertContains('function delete($id = null)', $result); | ||||
| 		$this->assertContains('if ($this->BakeArticle->delete())', $result); | ||||
| 		$this->assertContains("\$this->flash(__('Bake article deleted'), array('action' => 'index'))", $result); | ||||
| 		$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'ActionsWithNoSessions.ctp'); | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -511,9 +461,7 @@ class ControllerTaskTest extends CakeTestCase { | |||
| 		if ($count != count($this->fixtures)) { | ||||
| 			$this->markTestSkipped('Additional tables detected.'); | ||||
| 		} | ||||
| 		if (!defined('ARTICLE_MODEL_CREATED')) { | ||||
| 			$this->markTestSkipped('Execute into all could not be run as an Article, Tag or Comment model was already loaded.'); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('all'); | ||||
|  | @ -530,15 +478,45 @@ class ControllerTaskTest extends CakeTestCase { | |||
| 		$this->Task->execute(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test execute() with all and --admin | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteIntoAllAdmin() { | ||||
| 		$count = count($this->Task->listAll('test')); | ||||
| 		if ($count != count($this->fixtures)) { | ||||
| 			$this->markTestSkipped('Additional tables detected.'); | ||||
| 		} | ||||
| 
 | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('all'); | ||||
| 		$this->Task->params['admin'] = true; | ||||
| 
 | ||||
| 		$this->Task->Project->expects($this->any()) | ||||
| 			->method('getPrefix') | ||||
| 			->will($this->returnValue('admin_')); | ||||
| 		$this->Task->expects($this->any()) | ||||
| 			->method('_checkUnitTest') | ||||
| 			->will($this->returnValue(true)); | ||||
| 		$this->Task->Test->expects($this->once())->method('bake'); | ||||
| 
 | ||||
| 		$filename = '/my/path/BakeArticlesController.php'; | ||||
| 		$this->Task->expects($this->once())->method('createFile')->with( | ||||
| 			$filename, | ||||
| 			$this->stringContains('function admin_index') | ||||
| 		)->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->Task->execute(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that `cake bake controller foos` works. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteWithController() { | ||||
| 		if (!defined('ARTICLE_MODEL_CREATED')) { | ||||
| 			$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined'); | ||||
| 		} | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('BakeArticles'); | ||||
|  | @ -570,9 +548,6 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteWithControllerNameVariations($name) { | ||||
| 		if (!defined('ARTICLE_MODEL_CREATED')) { | ||||
| 			$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined.'); | ||||
| 		} | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array($name); | ||||
|  | @ -590,9 +565,6 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteWithPublicParam() { | ||||
| 		if (!defined('ARTICLE_MODEL_CREATED')) { | ||||
| 			$this->markTestSkipped('Execute with public param requires no Article, Tag or Comment model to be defined.'); | ||||
| 		} | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('BakeArticles'); | ||||
|  | @ -612,9 +584,6 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteWithControllerAndBoth() { | ||||
| 		if (!defined('ARTICLE_MODEL_CREATED')) { | ||||
| 			$this->markTestSkipped('Execute with controller and both requires no Article, Tag or Comment model to be defined.'); | ||||
| 		} | ||||
| 		$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_')); | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
|  | @ -634,9 +603,6 @@ class ControllerTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteWithControllerAndAdmin() { | ||||
| 		if (!defined('ARTICLE_MODEL_CREATED')) { | ||||
| 			$this->markTestSkipped('Execute with controller and admin requires no Article, Tag or Comment model to be defined.'); | ||||
| 		} | ||||
| 		$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_')); | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko