mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 00:03:58 +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 @@ | |||
| /** | ||||
|  * AclShell Test file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP :  Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  * @since         CakePHP v 1.2.0.7726 | ||||
|  * @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'); | ||||
|  | @ -115,6 +114,7 @@ class AclShellTest extends CakeTestCase { | |||
| 	public function testParsingModelAndForeignKey() { | ||||
| 		$result = $this->Task->parseIdentifier('Model.foreignKey'); | ||||
| 		$expected = array('model' => 'Model', 'foreign_key' => 'foreignKey'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->Task->parseIdentifier('mySuperUser'); | ||||
| 		$this->assertEquals('mySuperUser', $result); | ||||
|  | @ -253,7 +253,7 @@ class AclShellTest extends CakeTestCase { | |||
| 		$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); | ||||
| 		$this->Task->check(); | ||||
| 
 | ||||
| 		$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', '*'); | ||||
| 		$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'delete'); | ||||
| 		$this->Task->check(); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * ApiShellTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP :  Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  * @since         CakePHP v 1.2.0.7726 | ||||
|  * @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'); | ||||
|  | @ -43,7 +42,7 @@ class ApiShellTest extends CakeTestCase { | |||
| 		$this->Shell = $this->getMock( | ||||
| 			'ApiShell', | ||||
| 			array('in', 'out', 'createFile', 'hr', '_stop'), | ||||
| 			array(	$out, $out, $in) | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,20 +2,18 @@ | |||
| /** | ||||
|  * BakeShell 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 | ||||
|  * @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'); | ||||
|  | @ -30,9 +28,6 @@ App::uses('Controller', 'Controller'); | |||
| 
 | ||||
| if (!class_exists('UsersController')) { | ||||
| 	class UsersController extends Controller { | ||||
| 
 | ||||
| 		public $name = 'Users'; | ||||
| 
 | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -2,27 +2,31 @@ | |||
| /** | ||||
|  * CommandListShellTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP :  Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  * @since         CakePHP v 2.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('CommandListShell', 'Console/Command'); | ||||
| App::uses('ConsoleOutput', 'Console'); | ||||
| App::uses('ConsoleInput', 'Console'); | ||||
| App::uses('Shell', 'Console'); | ||||
| App::uses('CommandTask', 'Console/Command/Task'); | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * TestStringOutput | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  */ | ||||
| class TestStringOutput extends ConsoleOutput { | ||||
| 
 | ||||
| 	public $output = ''; | ||||
|  | @ -33,6 +37,11 @@ class TestStringOutput extends ConsoleOutput { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * CommandListShellTest | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  */ | ||||
| class CommandListShellTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  | @ -60,6 +69,12 @@ class CommandListShellTest extends CakeTestCase { | |||
| 			array('in', '_stop', 'clear'), | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 
 | ||||
| 		$this->Shell->Command = $this->getMock( | ||||
| 			'CommandTask', | ||||
| 			array('in', '_stop', 'clear'), | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -88,7 +103,7 @@ class CommandListShellTest extends CakeTestCase { | |||
| 		$expected = "/\[.*TestPluginTwo.*\] example, welcome/"; | ||||
| 		$this->assertRegExp($expected, $output); | ||||
| 
 | ||||
| 		$expected = "/\[.*CORE.*\] acl, api, bake, command_list, console, i18n, schema, test, testsuite, upgrade/"; | ||||
| 		$expected = "/\[.*CORE.*\] acl, api, bake, command_list, completion, console, i18n, schema, server, test, testsuite, upgrade/"; | ||||
| 		$this->assertRegExp($expected, $output); | ||||
| 
 | ||||
| 		$expected = "/\[.*app.*\] sample/"; | ||||
|  |  | |||
							
								
								
									
										261
									
								
								lib/Cake/Test/Case/Console/Command/CompletionShellTest.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										261
									
								
								lib/Cake/Test/Case/Console/Command/CompletionShellTest.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,261 @@ | |||
| <?php | ||||
| /** | ||||
|  * CompletionShellTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP :  Rapid Development Framework (http://cakephp.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 (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  * @since         CakePHP v 2.5 | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('CompletionShell', 'Console/Command'); | ||||
| App::uses('ConsoleOutput', 'Console'); | ||||
| App::uses('ConsoleInput', 'Console'); | ||||
| App::uses('Shell', 'Console'); | ||||
| App::uses('CommandTask', 'Console/Command/Task'); | ||||
| 
 | ||||
| /** | ||||
|  * TestCompletionStringOutput | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  */ | ||||
| class TestCompletionStringOutput extends ConsoleOutput { | ||||
| 
 | ||||
| 	public $output = ''; | ||||
| 
 | ||||
| 	protected function _write($message) { | ||||
| 		$this->output .= $message; | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * CompletionShellTest | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  */ | ||||
| class CompletionShellTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  * setUp method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		App::build(array( | ||||
| 			'Plugin' => array( | ||||
| 				CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS | ||||
| 			), | ||||
| 			'Console/Command' => array( | ||||
| 				CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS | ||||
| 			) | ||||
| 		), App::RESET); | ||||
| 		CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); | ||||
| 
 | ||||
| 		$out = new TestCompletionStringOutput(); | ||||
| 		$in = $this->getMock('ConsoleInput', array(), array(), '', false); | ||||
| 
 | ||||
| 		$this->Shell = $this->getMock( | ||||
| 			'CompletionShell', | ||||
| 			array('in', '_stop', 'clear'), | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 
 | ||||
| 		$this->Shell->Command = $this->getMock( | ||||
| 			'CommandTask', | ||||
| 			array('in', '_stop', 'clear'), | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * tearDown | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
| 		unset($this->Shell); | ||||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that the startup method supresses the shell header | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testStartup() { | ||||
| 		$this->Shell->runCommand('main', array()); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$needle = 'Welcome to CakePHP'; | ||||
| 		$this->assertTextNotContains($needle, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that main displays a warning | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testMain() { | ||||
| 		$this->Shell->runCommand('main', array()); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "/This command is not intended to be called manually/"; | ||||
| 		$this->assertRegExp($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test commands method that list all available commands | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCommands() { | ||||
| 		$this->Shell->runCommand('commands', array()); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "TestPlugin.example TestPlugin.test_plugin TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion console i18n schema server test testsuite upgrade sample\n"; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that options without argument returns the default options | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testOptionsNoArguments() { | ||||
| 		$this->Shell->runCommand('options', array()); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "--help -h --verbose -v --quiet -q\n"; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that options with a nonexisting command returns the default options | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testOptionsNonExistingCommand() { | ||||
| 		$this->Shell->runCommand('options', array('options', 'foo')); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "--help -h --verbose -v --quiet -q\n"; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that options with a existing command returns the proper options | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testOptions() { | ||||
| 		$this->Shell->runCommand('options', array('options', 'bake')); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "--help -h --verbose -v --quiet -q --connection -c --theme -t\n"; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that subCommands with a existing CORE command returns the proper sub commands | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommandsCorePlugin() { | ||||
| 		$this->Shell->runCommand('subCommands', array('subCommands', 'CORE.bake')); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "controller db_config fixture model plugin project test view\n"; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that subCommands with a existing APP command returns the proper sub commands (in this case none) | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommandsAppPlugin() { | ||||
| 		$this->Shell->runCommand('subCommands', array('subCommands', 'app.sample')); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = ''; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that subCommands with a existing plugin command returns the proper sub commands | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommandsPlugin() { | ||||
| 		$this->Shell->runCommand('subCommands', array('subCommands', 'TestPluginTwo.welcome')); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "say_hello\n"; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that subcommands without arguments returns nothing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommandsNoArguments() { | ||||
| 		$this->Shell->runCommand('subCommands', array()); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = ''; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that subcommands with a nonexisting command returns nothing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommandsNonExistingCommand() { | ||||
| 		$this->Shell->runCommand('subCommands', array('subCommands', 'foo')); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = ''; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that subcommands returns the available subcommands for the given command | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommands() { | ||||
| 		$this->Shell->runCommand('subCommands', array('subCommands', 'bake')); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = "controller db_config fixture model plugin project test view\n"; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that fuzzy returns nothing | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testFuzzy() { | ||||
| 		$this->Shell->runCommand('fuzzy', array()); | ||||
| 		$output = $this->Shell->stdout->output; | ||||
| 
 | ||||
| 		$expected = ''; | ||||
| 		$this->assertEquals($expected, $output); | ||||
| 	} | ||||
| } | ||||
|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * SchemaShellTest Test file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  * @since         CakePHP 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('ShellDispatcher', 'Console'); | ||||
|  | @ -31,17 +30,10 @@ App::uses('SchemaShell', 'Console/Command'); | |||
|  */ | ||||
| class SchemaShellTestSchema extends CakeSchema { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'MyApp' | ||||
|  */ | ||||
| 	public $name = 'SchemaShellTest'; | ||||
| 
 | ||||
| /** | ||||
|  * connection property | ||||
|  * | ||||
|  * @var string 'test' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $connection = 'test'; | ||||
| 
 | ||||
|  | @ -78,6 +70,14 @@ class SchemaShellTestSchema extends CakeSchema { | |||
| 		'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), | ||||
| 		'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), | ||||
| 	); | ||||
| 
 | ||||
| 	public $newone = array( | ||||
| 		'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), | ||||
| 		'testit' => array('type' => 'string', 'null' => false, 'default' => 'Title'), | ||||
| 		'created' => array('type' => 'datetime', 'null' => true, 'default' => null), | ||||
| 		'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), | ||||
| 		'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), | ||||
| 	); | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  | @ -92,8 +92,9 @@ class SchemaShellTest extends CakeTestCase { | |||
|  * | ||||
|  * @var array | ||||
|  */ | ||||
| 	public $fixtures = array('core.article', 'core.user', 'core.post', 'core.auth_user', 'core.author', | ||||
| 		'core.comment', 'core.test_plugin_comment' | ||||
| 	public $fixtures = array( | ||||
| 		'core.article', 'core.user', 'core.post', 'core.auth_user', 'core.author', | ||||
| 		'core.comment', 'core.test_plugin_comment', 'core.aco', 'core.aro', 'core.aros_aco', | ||||
| 	); | ||||
| 
 | ||||
| /** | ||||
|  | @ -134,7 +135,7 @@ class SchemaShellTest extends CakeTestCase { | |||
| 	public function testStartup() { | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->assertTrue(isset($this->Shell->Schema)); | ||||
| 		$this->assertTrue(is_a($this->Shell->Schema, 'CakeSchema')); | ||||
| 		$this->assertInstanceOf('CakeSchema', $this->Shell->Schema); | ||||
| 		$this->assertEquals(Inflector::camelize(Inflector::slug(APP_DIR)), $this->Shell->Schema->name); | ||||
| 		$this->assertEquals('schema.php', $this->Shell->Schema->file); | ||||
| 
 | ||||
|  | @ -294,7 +295,7 @@ class SchemaShellTest extends CakeTestCase { | |||
| 		$this->Shell->Schema->path = TMP; | ||||
| 		$this->Shell->Schema->expects($this->never())->method('read'); | ||||
| 
 | ||||
| 		$result = $this->Shell->generate(); | ||||
| 		$this->Shell->generate(); | ||||
| 		unlink(TMP . 'schema.php'); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -362,6 +363,90 @@ class SchemaShellTest extends CakeTestCase { | |||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test generate with specific models | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGenerateModels() { | ||||
| 		App::build(array( | ||||
| 			'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) | ||||
| 		), App::RESET); | ||||
| 		CakePlugin::load('TestPlugin'); | ||||
| 
 | ||||
| 		$this->db->cacheSources = false; | ||||
| 		$this->Shell->params = array( | ||||
| 			'plugin' => 'TestPlugin', | ||||
| 			'connection' => 'test', | ||||
| 			'models' => 'TestPluginComment', | ||||
| 			'force' => false, | ||||
| 			'overwrite' => true | ||||
| 		); | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->Schema->path = TMP . 'tests' . DS; | ||||
| 
 | ||||
| 		$this->Shell->generate(); | ||||
| 		$this->file = new File(TMP . 'tests' . DS . 'schema.php'); | ||||
| 		$contents = $this->file->read(); | ||||
| 
 | ||||
| 		$this->assertRegExp('/class TestPluginSchema/', $contents); | ||||
| 		$this->assertRegExp('/public \$test_plugin_comments/', $contents); | ||||
| 		$this->assertNotRegExp('/public \$authors/', $contents); | ||||
| 		$this->assertNotRegExp('/public \$auth_users/', $contents); | ||||
| 		$this->assertNotRegExp('/public \$posts/', $contents); | ||||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test generate with excluded tables | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGenerateExclude() { | ||||
| 		Configure::write('Acl.database', 'test'); | ||||
| 		$this->db->cacheSources = false; | ||||
| 		$this->Shell->params = array( | ||||
| 			'connection' => 'test', | ||||
| 			'force' => false, | ||||
| 			'models' => 'Aro, Aco, Permission', | ||||
| 			'overwrite' => true, | ||||
| 			'exclude' => 'acos, aros', | ||||
| 		); | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->Schema->path = TMP . 'tests' . DS; | ||||
| 
 | ||||
| 		$this->Shell->generate(); | ||||
| 		$this->file = new File(TMP . 'tests' . DS . 'schema.php'); | ||||
| 		$contents = $this->file->read(); | ||||
| 
 | ||||
| 		$this->assertNotContains('public $acos = array(', $contents); | ||||
| 		$this->assertNotContains('public $aros = array(', $contents); | ||||
| 		$this->assertContains('public $aros_acos = array(', $contents); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test schema run create with --yes option | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCreateOptionYes() { | ||||
| 		$this->Shell = $this->getMock( | ||||
| 			'SchemaShell', | ||||
| 			array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'), | ||||
| 			array(&$this->Dispatcher) | ||||
| 		); | ||||
| 
 | ||||
| 		$this->Shell->params = array( | ||||
| 			'connection' => 'test', | ||||
| 			'yes' => true, | ||||
| 		); | ||||
| 		$this->Shell->args = array('i18n'); | ||||
| 		$this->Shell->expects($this->never())->method('in'); | ||||
| 		$this->Shell->expects($this->exactly(2))->method('_run'); | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->create(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test schema run create with no table args. | ||||
|  * | ||||
|  | @ -394,15 +479,15 @@ class SchemaShellTest extends CakeTestCase { | |||
| 	public function testCreateWithTableArgs() { | ||||
| 		$db = ConnectionManager::getDataSource('test'); | ||||
| 		$sources = $db->listSources(); | ||||
| 		if (in_array('acos', $sources)) { | ||||
| 			$this->markTestSkipped('acos table already exists, cannot try to create it again.'); | ||||
| 		if (in_array('i18n', $sources)) { | ||||
| 			$this->markTestSkipped('i18n table already exists, cannot try to create it again.'); | ||||
| 		} | ||||
| 		$this->Shell->params = array( | ||||
| 			'connection' => 'test', | ||||
| 			'name' => 'DbAcl', | ||||
| 			'name' => 'I18n', | ||||
| 			'path' => APP . 'Config' . DS . 'Schema' | ||||
| 		); | ||||
| 		$this->Shell->args = array('DbAcl', 'acos'); | ||||
| 		$this->Shell->args = array('I18n', 'i18n'); | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y')); | ||||
| 		$this->Shell->create(); | ||||
|  | @ -410,12 +495,10 @@ class SchemaShellTest extends CakeTestCase { | |||
| 		$db = ConnectionManager::getDataSource('test'); | ||||
| 		$db->cacheSources = false; | ||||
| 		$sources = $db->listSources(); | ||||
| 		$this->assertTrue(in_array($db->config['prefix'] . 'acos', $sources), 'acos should be present.'); | ||||
| 		$this->assertFalse(in_array($db->config['prefix'] . 'aros', $sources), 'aros should not be found.'); | ||||
| 		$this->assertFalse(in_array('aros_acos', $sources), 'aros_acos should not be found.'); | ||||
| 		$this->assertTrue(in_array($db->config['prefix'] . 'i18n', $sources), 'i18n should be present.'); | ||||
| 
 | ||||
| 		$schema = new DbAclSchema(); | ||||
| 		$db->execute($db->dropSchema($schema, 'acos')); | ||||
| 		$schema = new I18nSchema(); | ||||
| 		$db->execute($db->dropSchema($schema, 'i18n')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -436,8 +519,66 @@ class SchemaShellTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->Shell->args = array('SchemaShellTest', 'articles'); | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->expects($this->any())->method('in')->will($this->returnValue('y')); | ||||
| 		$this->Shell->expects($this->once())->method('_run') | ||||
| 		$this->Shell->expects($this->any()) | ||||
| 			->method('in') | ||||
| 			->will($this->returnValue('y')); | ||||
| 		$this->Shell->expects($this->once()) | ||||
| 			->method('_run') | ||||
| 			->with($this->arrayHasKey('articles'), 'update', $this->isInstanceOf('CakeSchema')); | ||||
| 
 | ||||
| 		$this->Shell->update(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test run update with a table arg. and checks that a CREATE statement is issued | ||||
|  * table creation | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testUpdateWithTableCreate() { | ||||
| 		$this->Shell = $this->getMock( | ||||
| 			'SchemaShell', | ||||
| 			array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'), | ||||
| 			array(&$this->Dispatcher) | ||||
| 		); | ||||
| 
 | ||||
| 		$this->Shell->params = array( | ||||
| 			'connection' => 'test', | ||||
| 			'force' => true | ||||
| 		); | ||||
| 		$this->Shell->args = array('SchemaShellTest', 'newone'); | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->expects($this->any()) | ||||
| 			->method('in') | ||||
| 			->will($this->returnValue('y')); | ||||
| 		$this->Shell->expects($this->once()) | ||||
| 			->method('_run') | ||||
| 			->with($this->arrayHasKey('newone'), 'update', $this->isInstanceOf('CakeSchema')); | ||||
| 
 | ||||
| 		$this->Shell->update(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test run update with --yes option | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testUpdateWithOptionYes() { | ||||
| 		$this->Shell = $this->getMock( | ||||
| 			'SchemaShell', | ||||
| 			array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'), | ||||
| 			array(&$this->Dispatcher) | ||||
| 		); | ||||
| 
 | ||||
| 		$this->Shell->params = array( | ||||
| 			'connection' => 'test', | ||||
| 			'force' => true, | ||||
| 			'yes' => true, | ||||
| 		); | ||||
| 		$this->Shell->args = array('SchemaShellTest', 'articles'); | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->expects($this->never())->method('in'); | ||||
| 		$this->Shell->expects($this->once()) | ||||
| 			->method('_run') | ||||
| 			->with($this->arrayHasKey('articles'), 'update', $this->isInstanceOf('CakeSchema')); | ||||
| 
 | ||||
| 		$this->Shell->update(); | ||||
|  | @ -463,6 +604,71 @@ class SchemaShellTest extends CakeTestCase { | |||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that underscored names also result in CamelCased class names | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testName() { | ||||
| 		App::build(array( | ||||
| 			'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) | ||||
| 		)); | ||||
| 		CakePlugin::load('TestPlugin'); | ||||
| 		$this->Shell->params = array( | ||||
| 			'plugin' => 'TestPlugin', | ||||
| 			'connection' => 'test', | ||||
| 			'name' => 'custom_names', | ||||
| 			'force' => false, | ||||
| 			'overwrite' => true, | ||||
| 		); | ||||
| 		$this->Shell->startup(); | ||||
| 		if (file_exists($this->Shell->Schema->path . DS . 'custom_names.php')) { | ||||
| 			unlink($this->Shell->Schema->path . DS . 'custom_names.php'); | ||||
| 		} | ||||
| 		$this->Shell->generate(); | ||||
| 
 | ||||
| 		$contents = file_get_contents($this->Shell->Schema->path . DS . 'custom_names.php'); | ||||
| 		$this->assertRegExp('/class CustomNamesSchema/', $contents); | ||||
| 		unlink($this->Shell->Schema->path . DS . 'custom_names.php'); | ||||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that passing name and file creates the passed filename with the | ||||
|  * passed class name | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testNameAndFile() { | ||||
| 		App::build(array( | ||||
| 			'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) | ||||
| 		)); | ||||
| 		CakePlugin::load('TestPlugin'); | ||||
| 		$this->Shell->params = array( | ||||
| 			'plugin' => 'TestPlugin', | ||||
| 			'connection' => 'test', | ||||
| 			'name' => 'custom_name', | ||||
| 			'file' => 'other_name', | ||||
| 			'force' => false, | ||||
| 			'overwrite' => true, | ||||
| 		); | ||||
| 		$this->Shell->startup(); | ||||
| 		$file = $this->Shell->Schema->path . DS . 'other_name.php'; | ||||
| 		if (file_exists($file)) { | ||||
| 			unlink($file); | ||||
| 		} | ||||
| 		$this->Shell->generate(); | ||||
| 
 | ||||
| 		$this->assertFileExists($file); | ||||
| 		$contents = file_get_contents($file); | ||||
| 		$this->assertRegExp('/class CustomNameSchema/', $contents); | ||||
| 
 | ||||
| 		if (file_exists($file)) { | ||||
| 			unlink($file); | ||||
| 		} | ||||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that using Plugin.name with write. | ||||
|  * | ||||
|  |  | |||
							
								
								
									
										242
									
								
								lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										242
									
								
								lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,242 @@ | |||
| <?php | ||||
| /** | ||||
|  * CakePHP : Rapid Development Framework (http://cakephp.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 (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  * @since         CakePHP v 2.5 | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('CommandTask', 'Console/Command/Task'); | ||||
| 
 | ||||
| /** | ||||
|  * CommandTaskTest class | ||||
|  * | ||||
|  * @package   Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class CommandTaskTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  * setUp method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		App::build(array( | ||||
| 			'Plugin' => array( | ||||
| 				CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS | ||||
| 			), | ||||
| 			'Console/Command' => array( | ||||
| 				CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS | ||||
| 			) | ||||
| 		), App::RESET); | ||||
| 		CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); | ||||
| 
 | ||||
| 		$out = $this->getMock('ConsoleOutput', array(), array(), '', false); | ||||
| 		$in = $this->getMock('ConsoleInput', array(), array(), '', false); | ||||
| 
 | ||||
| 		$this->CommandTask = $this->getMock( | ||||
| 			'CommandTask', | ||||
| 			array('in', '_stop', 'clear'), | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * tearDown | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
| 		unset($this->CommandTask); | ||||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the resulting list of shells | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGetShellList() { | ||||
| 		$result = $this->CommandTask->getShellList(); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'CORE' => array( | ||||
| 				'acl', | ||||
| 				'api', | ||||
| 				'bake', | ||||
| 				'command_list', | ||||
| 				'completion', | ||||
| 				'console', | ||||
| 				'i18n', | ||||
| 				'schema', | ||||
| 				'server', | ||||
| 				'test', | ||||
| 				'testsuite', | ||||
| 				'upgrade' | ||||
| 			), | ||||
| 			'TestPlugin' => array( | ||||
| 				'example', | ||||
| 				'test_plugin' | ||||
| 			), | ||||
| 			'TestPluginTwo' => array( | ||||
| 				'example', | ||||
| 				'welcome' | ||||
| 			), | ||||
| 			'app' => array( | ||||
| 				'sample' | ||||
| 			), | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the resulting list of commands | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCommands() { | ||||
| 		$result = $this->CommandTask->commands(); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'TestPlugin.example', | ||||
| 			'TestPlugin.test_plugin', | ||||
| 			'TestPluginTwo.example', | ||||
| 			'TestPluginTwo.welcome', | ||||
| 			'acl', | ||||
| 			'api', | ||||
| 			'bake', | ||||
| 			'command_list', | ||||
| 			'completion', | ||||
| 			'console', | ||||
| 			'i18n', | ||||
| 			'schema', | ||||
| 			'server', | ||||
| 			'test', | ||||
| 			'testsuite', | ||||
| 			'upgrade', | ||||
| 			'sample' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the resulting list of subcommands for the given command | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommands() { | ||||
| 		$result = $this->CommandTask->subCommands('acl'); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'check', | ||||
| 			'create', | ||||
| 			'db_config', | ||||
| 			'delete', | ||||
| 			'deny', | ||||
| 			'getPath', | ||||
| 			'grant', | ||||
| 			'inherit', | ||||
| 			'initdb', | ||||
| 			'nodeExists', | ||||
| 			'parseIdentifier', | ||||
| 			'setParent', | ||||
| 			'view' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that unknown commands return an empty array | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSubCommandsUnknownCommand() { | ||||
| 		$result = $this->CommandTask->subCommands('yoghurt'); | ||||
| 
 | ||||
| 		$expected = array(); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that getting a existing shell returns the shell instance | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGetShell() { | ||||
| 		$result = $this->CommandTask->getShell('acl'); | ||||
| 		$this->assertInstanceOf('AclShell', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that getting a non-existing shell returns false | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGetShellNonExisting() { | ||||
| 		$result = $this->CommandTask->getShell('strawberry'); | ||||
| 		$this->assertFalse($result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that getting a existing core shell with 'core.' prefix returns the correct shell instance | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGetShellCore() { | ||||
| 		$result = $this->CommandTask->getShell('core.bake'); | ||||
| 		$this->assertInstanceOf('BakeShell', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the options array for a known command | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testOptions() { | ||||
| 		$result = $this->CommandTask->options('bake'); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'--help', | ||||
| 			'-h', | ||||
| 			'--verbose', | ||||
| 			'-v', | ||||
| 			'--quiet', | ||||
| 			'-q', | ||||
| 			'--connection', | ||||
| 			'-c', | ||||
| 			'--theme', | ||||
| 			'-t' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the options array for an unknown command | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testOptionsUnknownCommand() { | ||||
| 		$result = $this->CommandTask->options('pie'); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'--help', | ||||
| 			'-h', | ||||
| 			'--verbose', | ||||
| 			'-v', | ||||
| 			'--quiet', | ||||
| 			'-q' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | @ -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/'; | ||||
|  |  | |||
|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * DBConfigTask 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('ShellDispatcher', 'Console'); | ||||
|  | @ -101,7 +100,7 @@ class DbConfigTaskTest extends CakeTestCase { | |||
| 		$this->Task->expects($this->once())->method('_stop'); | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('default')); //name
 | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('mysql')); //db type
 | ||||
| 		$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('n')); //persistant
 | ||||
| 		$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('n')); //persistent
 | ||||
| 		$this->Task->expects($this->at(3))->method('in')->will($this->returnValue('localhost')); //server
 | ||||
| 		$this->Task->expects($this->at(4))->method('in')->will($this->returnValue('n')); //port
 | ||||
| 		$this->Task->expects($this->at(5))->method('in')->will($this->returnValue('root')); //user
 | ||||
|  | @ -128,6 +127,6 @@ class DbConfigTaskTest extends CakeTestCase { | |||
| 				) | ||||
| 			)); | ||||
| 
 | ||||
| 		$result = $this->Task->execute(); | ||||
| 		$this->Task->execute(); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -4,19 +4,18 @@ | |||
|  * | ||||
|  * Test Case for i18n extraction shell task | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP :  Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @since         CakePHP v 1.2.0.7726 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Folder', 'Utility'); | ||||
|  | @ -49,7 +48,7 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 		$this->path = TMP . 'tests' . DS . 'extract_task_test'; | ||||
| 		$Folder = new Folder($this->path . DS . 'locale', true); | ||||
| 		new Folder($this->path . DS . 'locale', true); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -136,23 +135,23 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		// extract.ctp
 | ||||
| 		$pattern = '/\#: (\\\\|\/)extract\.ctp:15;6\n'; | ||||
| 		$pattern = '/\#: extract\.ctp:15;6\n'; | ||||
| 		$pattern .= 'msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/'; | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = '/msgid "You have %d new message."\nmsgstr ""/'; | ||||
| 		$this->assertNotRegExp($pattern, $result, 'No duplicate msgid'); | ||||
| 
 | ||||
| 		$pattern = '/\#: (\\\\|\/)extract\.ctp:7\n'; | ||||
| 		$pattern = '/\#: extract\.ctp:7\n'; | ||||
| 		$pattern .= 'msgid "You deleted %d message."\nmsgid_plural "You deleted %d messages."/'; | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = '/\#: (\\\\|\/)extract\.ctp:14\n'; | ||||
| 		$pattern .= '\#: (\\\\|\/)home\.ctp:99\n'; | ||||
| 		$pattern = '/\#: extract\.ctp:14\n'; | ||||
| 		$pattern .= '\#: home\.ctp:68\n'; | ||||
| 		$pattern .= 'msgid "Editing this Page"\nmsgstr ""/'; | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = '/\#: (\\\\|\/)extract\.ctp:22\nmsgid "'; | ||||
| 		$pattern = '/\#: extract\.ctp:22\nmsgid "'; | ||||
| 		$pattern .= 'Hot features!'; | ||||
| 		$pattern .= '\\\n - No Configuration: Set-up the database and let the magic begin'; | ||||
| 		$pattern .= '\\\n - Extremely Simple: Just look at the name...It\'s Cake'; | ||||
|  | @ -163,6 +162,21 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->assertContains('msgid "double \\"quoted\\""', $result, 'Strings with quotes not handled correctly'); | ||||
| 		$this->assertContains("msgid \"single 'quoted'\"", $result, 'Strings with quotes not handled correctly'); | ||||
| 
 | ||||
| 		$pattern = '/\#: extract\.ctp:36\nmsgid "letter"/'; | ||||
| 		$this->assertRegExp($pattern, $result, 'Strings with context should not overwrite strings without context'); | ||||
| 
 | ||||
| 		$pattern = '/\#: extract\.ctp:37;39\nmsgctxt "A"\nmsgid "letter"/'; | ||||
| 		$this->assertRegExp($pattern, $result, 'Should contain string with context "A"'); | ||||
| 
 | ||||
| 		$pattern = '/\#: extract\.ctp:38\nmsgctxt "B"\nmsgid "letter"/'; | ||||
| 		$this->assertRegExp($pattern, $result, 'Should contain string with context "B"'); | ||||
| 
 | ||||
| 		$pattern = '/\#: extract\.ctp:40\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; | ||||
| 		$this->assertRegExp($pattern, $result, 'Plural strings with context should not overwrite strings without context'); | ||||
| 
 | ||||
| 		$pattern = '/\#: extract\.ctp:41\nmsgctxt "A"\nmsgid "%d letter"\nmsgid_plural "%d letters"/'; | ||||
| 		$this->assertRegExp($pattern, $result, 'Should contain plural string with context "A"'); | ||||
| 
 | ||||
| 		// extract.ctp - reading the domain.pot
 | ||||
| 		$result = file_get_contents($this->path . DS . 'domain.pot'); | ||||
| 
 | ||||
|  | @ -177,6 +191,64 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->assertRegExp($pattern, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testExtractCategory method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExtractCategory() { | ||||
| 		$this->Task->interactive = false; | ||||
| 
 | ||||
| 		$this->Task->params['paths'] = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages'; | ||||
| 		$this->Task->params['output'] = $this->path . DS; | ||||
| 		$this->Task->params['extract-core'] = 'no'; | ||||
| 		$this->Task->params['merge'] = 'no'; | ||||
| 		$this->Task->expects($this->never())->method('err'); | ||||
| 		$this->Task->expects($this->any())->method('in') | ||||
| 			->will($this->returnValue('y')); | ||||
| 		$this->Task->expects($this->never())->method('_stop'); | ||||
| 
 | ||||
| 		$this->Task->execute(); | ||||
| 		$this->assertTrue(file_exists($this->path . DS . 'LC_NUMERIC' . DS . 'default.pot')); | ||||
| 		$this->assertFalse(file_exists($this->path . DS . 'LC_TIME' . DS . 'default.pot')); | ||||
| 
 | ||||
| 		$result = file_get_contents($this->path . DS . 'default.pot'); | ||||
| 
 | ||||
| 		$pattern = '/\#: .*extract\.ctp:31\n/'; | ||||
| 		$this->assertNotRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = '/\#: .*extract\.ctp:33\n/'; | ||||
| 		$this->assertNotRegExp($pattern, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testExtractWithoutLocations method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExtractWithoutLocations() { | ||||
| 		$this->Task->interactive = false; | ||||
| 
 | ||||
| 		$this->Task->params['paths'] = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages'; | ||||
| 		$this->Task->params['output'] = $this->path . DS; | ||||
| 		$this->Task->params['extract-core'] = 'no'; | ||||
| 		$this->Task->params['merge'] = 'no'; | ||||
| 		$this->Task->params['no-location'] = true; | ||||
| 
 | ||||
| 		$this->Task->expects($this->never())->method('err'); | ||||
| 		$this->Task->expects($this->any())->method('in') | ||||
| 			->will($this->returnValue('y')); | ||||
| 		$this->Task->expects($this->never())->method('_stop'); | ||||
| 
 | ||||
| 		$this->Task->execute(); | ||||
| 		$this->assertTrue(file_exists($this->path . DS . 'default.pot')); | ||||
| 
 | ||||
| 		$result = file_get_contents($this->path . DS . 'default.pot'); | ||||
| 
 | ||||
| 		$pattern = '/\n\#: .*\n/'; | ||||
| 		$this->assertNotRegExp($pattern, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test exclusions | ||||
|  * | ||||
|  | @ -267,7 +339,7 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); | ||||
| 		$this->in = $this->getMock('ConsoleInput', array(), array(), '', false); | ||||
| 		$this->Task = $this->getMock('ExtractTask', | ||||
| 			array('_isExtractingApp', '_extractValidationMessages', 'in', 'out', 'err', 'clear', '_stop'), | ||||
| 			array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'), | ||||
| 			array($this->out, $this->out, $this->in) | ||||
| 		); | ||||
| 
 | ||||
|  | @ -279,6 +351,7 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->assertNotRegExp('#Pages#', $result); | ||||
| 		$this->assertContains('translate.ctp:1', $result); | ||||
| 		$this->assertContains('This is a translatable string', $result); | ||||
| 		$this->assertContains('I can haz plugin model validation message', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -308,10 +381,10 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->Task->execute(); | ||||
| 		$result = file_get_contents($this->path . DS . 'default.pot'); | ||||
| 
 | ||||
| 		$pattern = preg_quote('#Model' . DS . 'PersisterOne.php:validation for field title#', '\\'); | ||||
| 		$pattern = preg_quote('#Model/PersisterOne.php:validation for field title#', '\\'); | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = preg_quote('#Model' . DS . 'PersisterOne.php:validation for field body#', '\\'); | ||||
| 		$pattern = preg_quote('#Model/PersisterOne.php:validation for field body#', '\\'); | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = '#msgid "Post title is required"#'; | ||||
|  | @ -325,6 +398,9 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 
 | ||||
| 		$pattern = '#msgid "Post body is super required"#'; | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$this->assertContains('msgid "double \\"quoted\\" validation"', $result, 'Strings with quotes not handled correctly'); | ||||
| 		$this->assertContains("msgid \"single 'quoted' validation\"", $result, 'Strings with quotes not handled correctly'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -354,10 +430,10 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->Task->execute(); | ||||
| 		$result = file_get_contents($this->path . DS . 'test_plugin.pot'); | ||||
| 
 | ||||
| 		$pattern = preg_quote('#Plugin' . DS . 'TestPlugin' . DS . 'Model' . DS . 'TestPluginPost.php:validation for field title#', '\\'); | ||||
| 		$pattern = preg_quote('#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title#', '\\'); | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = preg_quote('#Plugin' . DS . 'TestPlugin' . DS . 'Model' . DS . 'TestPluginPost.php:validation for field body#', '\\'); | ||||
| 		$pattern = preg_quote('#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field body#', '\\'); | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = '#msgid "Post title is required"#'; | ||||
|  | @ -393,10 +469,10 @@ class ExtractTaskTest extends CakeTestCase { | |||
| 		$this->Task->execute(); | ||||
| 		$result = file_get_contents($this->path . DS . 'test_plugin.pot'); | ||||
| 
 | ||||
| 		$pattern = preg_quote('#Model' . DS . 'TestPluginPost.php:validation for field title#', '\\'); | ||||
| 		$pattern = preg_quote('#Model/TestPluginPost.php:validation for field title#', '\\'); | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = preg_quote('#Model' . DS . 'TestPluginPost.php:validation for field body#', '\\'); | ||||
| 		$pattern = preg_quote('#Model/TestPluginPost.php:validation for field body#', '\\'); | ||||
| 		$this->assertRegExp($pattern, $result); | ||||
| 
 | ||||
| 		$pattern = '#msgid "Post title is required"#'; | ||||
|  |  | |||
|  | @ -2,19 +2,18 @@ | |||
| /** | ||||
|  * FixtureTask 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('ShellDispatcher', 'Console'); | ||||
|  | @ -43,7 +42,7 @@ class FixtureTaskTest extends CakeTestCase { | |||
| /** | ||||
|  * Whether backup global state for each test method or not | ||||
|  * | ||||
|  * @var bool false | ||||
|  * @var bool | ||||
|  */ | ||||
| 	public $backupGlobals = false; | ||||
| 
 | ||||
|  | @ -99,6 +98,7 @@ class FixtureTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testImportOptionsSchemaRecords() { | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y')); | ||||
| 
 | ||||
|  | @ -113,6 +113,7 @@ class FixtureTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testImportOptionsNothing() { | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n')); | ||||
| 		$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('n')); | ||||
|  | @ -122,12 +123,70 @@ class FixtureTaskTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test importOptions with overwriting command line options. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testImportOptionsWithCommandLineOptions() { | ||||
| 		$this->Task->params = array('schema' => true, 'records' => true); | ||||
| 
 | ||||
| 		$result = $this->Task->importOptions('Article'); | ||||
| 		$expected = array('schema' => 'Article', 'fromTable' => true); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test importOptions with overwriting CLI options | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testImportOptionsWithCommandLineOptionsPlugin() { | ||||
| 		$this->Task->params = array('schema' => true, 'records' => true, 'plugin' => 'TestPlugin'); | ||||
| 
 | ||||
| 		$result = $this->Task->importOptions('Article'); | ||||
| 		$expected = array('schema' => 'TestPlugin.Article', 'fromTable' => true); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test importOptions with schema. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testImportOptionsWithSchema() { | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->params = array('schema' => true); | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n')); | ||||
| 
 | ||||
| 		$result = $this->Task->importOptions('Article'); | ||||
| 		$expected = array('schema' => 'Article'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test importOptions with records. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testImportOptionsWithRecords() { | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->params = array('records' => true); | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n')); | ||||
| 
 | ||||
| 		$result = $this->Task->importOptions('Article'); | ||||
| 		$expected = array('fromTable' => true); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test importOptions choosing from Table. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testImportOptionsTable() { | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n')); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n')); | ||||
| 		$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y')); | ||||
|  | @ -145,6 +204,9 @@ class FixtureTaskTest extends CakeTestCase { | |||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->expects($this->at(0))->method('in') | ||||
| 			->will($this->returnValue('WHERE 1=1')); | ||||
| 		$this->Task->expects($this->at(1))->method('in') | ||||
| 			->with($this->anything(), $this->anything(), '3') | ||||
| 			->will($this->returnValue('2')); | ||||
| 
 | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
|  | @ -156,9 +218,8 @@ class FixtureTaskTest extends CakeTestCase { | |||
| 		$this->assertContains('class ArticleFixture extends CakeTestFixture', $result); | ||||
| 		$this->assertContains('public $records', $result); | ||||
| 		$this->assertContains('public $import', $result); | ||||
| 		$this->assertContains("'title' => 'First Article'", $result, 'Missing import data %s'); | ||||
| 		$this->assertContains('Second Article', $result, 'Missing import data %s'); | ||||
| 		$this->assertContains('Third Article', $result, 'Missing import data %s'); | ||||
| 		$this->assertContains("'title' => 'First Article'", $result, 'Missing import data'); | ||||
| 		$this->assertContains('Second Article', $result, 'Missing import data'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -202,8 +263,63 @@ class FixtureTaskTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that execute passes runs bake depending with named model. | ||||
|  * test that execute includes import options | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteWithImportSchema() { | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('article'); | ||||
| 		$this->Task->params = array( | ||||
| 			'schema' => true, | ||||
| 			'records' => false, | ||||
| 		); | ||||
| 		$filename = '/my/path/ArticleFixture.php'; | ||||
| 
 | ||||
| 		$this->Task->expects($this->never()) | ||||
| 			->method('in'); | ||||
| 
 | ||||
| 		$this->Task->expects($this->at(0)) | ||||
| 			->method('createFile') | ||||
| 			->with($filename, $this->logicalAnd( | ||||
| 				$this->stringContains('class ArticleFixture'), | ||||
| 				$this->stringContains("\$import = array('model' => 'Article'") | ||||
| 			)); | ||||
| 
 | ||||
| 		$this->Task->execute(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that execute includes import options | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExecuteWithImportRecords() { | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('article'); | ||||
| 		$this->Task->params = array( | ||||
| 			'schema' => true, | ||||
| 			'records' => true, | ||||
| 		); | ||||
| 		$filename = '/my/path/ArticleFixture.php'; | ||||
| 
 | ||||
| 		$this->Task->expects($this->never()) | ||||
| 			->method('in'); | ||||
| 
 | ||||
| 		$this->Task->expects($this->at(0)) | ||||
| 			->method('createFile') | ||||
| 			->with($filename, $this->logicalAnd( | ||||
| 				$this->stringContains('class ArticleFixture'), | ||||
| 				$this->stringContains("\$import = array('model' => 'Article', 'connection' => 'test')") | ||||
| 			)); | ||||
| 
 | ||||
| 		$this->Task->execute(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that execute passes runs bake depending with named model. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -271,6 +387,32 @@ class FixtureTaskTest extends CakeTestCase { | |||
| 		$this->Task->all(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test using all() with -schema | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAllWithSchemaImport() { | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('all'); | ||||
| 		$this->Task->params = array('schema' => true); | ||||
| 
 | ||||
| 		$this->Task->Model->expects($this->any())->method('listAll') | ||||
| 			->will($this->returnValue(array('Articles', 'comments'))); | ||||
| 
 | ||||
| 		$filename = '/my/path/ArticleFixture.php'; | ||||
| 		$this->Task->expects($this->at(0))->method('createFile') | ||||
| 			->with($filename, $this->stringContains('public $import = array(\'model\' => \'Article\'')); | ||||
| 
 | ||||
| 		$filename = '/my/path/CommentFixture.php'; | ||||
| 		$this->Task->expects($this->at(1))->method('createFile') | ||||
| 			->with($filename, $this->stringContains('public $import = array(\'model\' => \'Comment\'')); | ||||
| 		$this->Task->expects($this->exactly(2))->method('createFile'); | ||||
| 
 | ||||
| 		$this->Task->all(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test interactive mode of execute | ||||
|  * | ||||
|  | @ -360,9 +502,8 @@ class FixtureTaskTest extends CakeTestCase { | |||
| 		$this->Task->expects($this->at(1))->method('createFile') | ||||
| 			->with($filename, $this->stringContains('<?php')); | ||||
| 
 | ||||
| 		$result = $this->Task->generateFixtureFile('Article', array()); | ||||
| 
 | ||||
| 		$result = $this->Task->generateFixtureFile('Article', array()); | ||||
| 		$this->Task->generateFixtureFile('Article', array()); | ||||
| 		$this->Task->generateFixtureFile('Article', array()); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -381,7 +522,7 @@ class FixtureTaskTest extends CakeTestCase { | |||
| 		$this->Task->expects($this->at(0))->method('createFile') | ||||
| 			->with($filename, $this->stringContains('class Article')); | ||||
| 
 | ||||
| 		$result = $this->Task->generateFixtureFile('Article', array()); | ||||
| 		$this->Task->generateFixtureFile('Article', array()); | ||||
| 		CakePlugin::unload(); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,19 +4,18 @@ | |||
|  * | ||||
|  * Test Case for test generation shell task | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @since         CakePHP v 1.2.6 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('ShellDispatcher', 'Console'); | ||||
|  | @ -31,6 +30,7 @@ App::uses('ModelTask', 'Console/Command/Task'); | |||
|  * ModelTaskTest class | ||||
|  * | ||||
|  * @package	   Cake.Test.Case.Console.Command.Task | ||||
|  * @property   ModelTask $Task | ||||
|  */ | ||||
| class ModelTaskTest extends CakeTestCase { | ||||
| 
 | ||||
|  | @ -41,7 +41,7 @@ class ModelTaskTest extends CakeTestCase { | |||
|  */ | ||||
| 	public $fixtures = array( | ||||
| 		'core.bake_article', 'core.bake_comment', 'core.bake_articles_bake_tag', | ||||
| 		'core.bake_tag', 'core.category_thread' | ||||
| 		'core.bake_tag', 'core.category_thread', 'core.number_tree' | ||||
| 	); | ||||
| 
 | ||||
| /** | ||||
|  | @ -62,7 +62,7 @@ class ModelTaskTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Setup a mock that has out mocked.  Normally this is not used as it makes $this->at() really tricky. | ||||
|  * Setup a mock that has out mocked. Normally this is not used as it makes $this->at() really tricky. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -173,7 +173,7 @@ class ModelTaskTest extends CakeTestCase { | |||
| 		$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls(99, 1)); | ||||
| 		$this->Task->expects($this->once())->method('err'); | ||||
| 
 | ||||
| 		$result = $this->Task->getName('test'); | ||||
| 		$this->Task->getName('test'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -189,7 +189,7 @@ class ModelTaskTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test gettting a custom table name. | ||||
|  * test getting a custom table name. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -268,7 +268,7 @@ class ModelTaskTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testInitValidations() { | ||||
| 		$result = $this->Task->initValidations(); | ||||
| 		$this->assertTrue(in_array('notempty', $result)); | ||||
| 		$this->assertTrue(in_array('notBlank', $result)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -282,7 +282,7 @@ class ModelTaskTest extends CakeTestCase { | |||
| 		$this->Task->initValidations(); | ||||
| 
 | ||||
| 		$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); | ||||
| 		$expected = array('notempty' => 'notempty'); | ||||
| 		$expected = array('notBlank' => 'notBlank'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false)); | ||||
|  | @ -315,10 +315,10 @@ class ModelTaskTest extends CakeTestCase { | |||
| 		$this->Task->initValidations(); | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->expects($this->any())->method('in') | ||||
| 			->will($this->onConsecutiveCalls('23', 'y', '17', 'n')); | ||||
| 			->will($this->onConsecutiveCalls('24', 'y', '18', 'n')); | ||||
| 
 | ||||
| 		$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); | ||||
| 		$expected = array('notempty' => 'notempty', 'maxlength' => 'maxlength'); | ||||
| 		$expected = array('notBlank' => 'notBlank', 'maxLength' => 'maxLength'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -333,13 +333,13 @@ class ModelTaskTest extends CakeTestCase { | |||
| 		$this->Task->interactive = true; | ||||
| 
 | ||||
| 		$this->Task->expects($this->any())->method('in') | ||||
| 			->will($this->onConsecutiveCalls('999999', '23', 'n')); | ||||
| 			->will($this->onConsecutiveCalls('999999', '24', 'n')); | ||||
| 
 | ||||
| 		$this->Task->expects($this->at(10))->method('out') | ||||
| 			->with($this->stringContains('make a valid')); | ||||
| 
 | ||||
| 		$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); | ||||
| 		$expected = array('notempty' => 'notempty'); | ||||
| 		$expected = array('notBlank' => 'notBlank'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -359,6 +359,100 @@ class ModelTaskTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that skipping fields during rule choice works when doing interactive field validation. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSkippingChoiceInteractiveFieldValidation() { | ||||
| 		$this->Task->initValidations(); | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->expects($this->any())->method('in') | ||||
| 			->will($this->onConsecutiveCalls('24', 'y', 's')); | ||||
| 
 | ||||
| 		$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); | ||||
| 		$expected = array('notBlank' => 'notBlank', '_skipFields' => true); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that skipping fields after rule choice works when doing interactive field validation. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSkippingAnotherInteractiveFieldValidation() { | ||||
| 		$this->Task->initValidations(); | ||||
| 		$this->Task->interactive = true; | ||||
| 		$this->Task->expects($this->any())->method('in') | ||||
| 			->will($this->onConsecutiveCalls('24', 's')); | ||||
| 
 | ||||
| 		$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); | ||||
| 		$expected = array('notBlank' => 'notBlank', '_skipFields' => true); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the validation generation routine with skipping the rest of the fields | ||||
|  * when doing interactive field validation. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testInteractiveDoValidationWithSkipping() { | ||||
| 		$this->Task->expects($this->any()) | ||||
| 			->method('in') | ||||
| 			->will($this->onConsecutiveCalls('35', '24', 'n', '10', 's')); | ||||
| 		$this->Task->interactive = true; | ||||
| 		$Model = $this->getMock('Model'); | ||||
| 		$Model->primaryKey = 'id'; | ||||
| 		$Model->expects($this->any()) | ||||
| 			->method('schema') | ||||
| 			->will($this->returnValue(array( | ||||
| 					'id' => array( | ||||
| 						'type' => 'integer', | ||||
| 						'length' => 11, | ||||
| 						'null' => false, | ||||
| 						'key' => 'primary', | ||||
| 					), | ||||
| 					'name' => array( | ||||
| 						'type' => 'string', | ||||
| 						'length' => 20, | ||||
| 						'null' => false, | ||||
| 					), | ||||
| 					'email' => array( | ||||
| 						'type' => 'string', | ||||
| 						'length' => 255, | ||||
| 						'null' => false, | ||||
| 					), | ||||
| 					'some_date' => array( | ||||
| 						'type' => 'date', | ||||
| 						'length' => '', | ||||
| 						'null' => false, | ||||
| 					), | ||||
| 					'some_time' => array( | ||||
| 						'type' => 'time', | ||||
| 						'length' => '', | ||||
| 						'null' => false, | ||||
| 					), | ||||
| 					'created' => array( | ||||
| 						'type' => 'datetime', | ||||
| 						'length' => '', | ||||
| 						'null' => false, | ||||
| 					) | ||||
| 				) | ||||
| 			)); | ||||
| 
 | ||||
| 		$result = $this->Task->doValidation($Model); | ||||
| 		$expected = array( | ||||
| 			'name' => array( | ||||
| 				'notBlank' => 'notBlank' | ||||
| 			), | ||||
| 			'email' => array( | ||||
| 				'email' => 'email', | ||||
| 			), | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test the validation Generation routine | ||||
|  * | ||||
|  | @ -367,45 +461,48 @@ class ModelTaskTest extends CakeTestCase { | |||
| 	public function testNonInteractiveDoValidation() { | ||||
| 		$Model = $this->getMock('Model'); | ||||
| 		$Model->primaryKey = 'id'; | ||||
| 		$Model->expects($this->any())->method('schema')->will($this->returnValue(array( | ||||
| 			'id' => array( | ||||
| 				'type' => 'integer', | ||||
| 				'length' => 11, | ||||
| 				'null' => false, | ||||
| 				'key' => 'primary', | ||||
| 			), | ||||
| 			'name' => array( | ||||
| 				'type' => 'string', | ||||
| 				'length' => 20, | ||||
| 				'null' => false, | ||||
| 			), | ||||
| 			'email' => array( | ||||
| 				'type' => 'string', | ||||
| 				'length' => 255, | ||||
| 				'null' => false, | ||||
| 			), | ||||
| 			'some_date' => array( | ||||
| 				'type' => 'date', | ||||
| 				'length' => '', | ||||
| 				'null' => false, | ||||
| 			), | ||||
| 			'some_time' => array( | ||||
| 				'type' => 'time', | ||||
| 				'length' => '', | ||||
| 				'null' => false, | ||||
| 			), | ||||
| 			'created' => array( | ||||
| 				'type' => 'datetime', | ||||
| 				'length' => '', | ||||
| 				'null' => false, | ||||
| 		$Model->expects($this->any()) | ||||
| 			->method('schema') | ||||
| 			->will($this->returnValue(array( | ||||
| 				'id' => array( | ||||
| 					'type' => 'integer', | ||||
| 					'length' => 11, | ||||
| 					'null' => false, | ||||
| 					'key' => 'primary', | ||||
| 				), | ||||
| 				'name' => array( | ||||
| 					'type' => 'string', | ||||
| 					'length' => 20, | ||||
| 					'null' => false, | ||||
| 				), | ||||
| 				'email' => array( | ||||
| 					'type' => 'string', | ||||
| 					'length' => 255, | ||||
| 					'null' => false, | ||||
| 				), | ||||
| 				'some_date' => array( | ||||
| 					'type' => 'date', | ||||
| 					'length' => '', | ||||
| 					'null' => false, | ||||
| 				), | ||||
| 				'some_time' => array( | ||||
| 					'type' => 'time', | ||||
| 					'length' => '', | ||||
| 					'null' => false, | ||||
| 				), | ||||
| 				'created' => array( | ||||
| 					'type' => 'datetime', | ||||
| 					'length' => '', | ||||
| 					'null' => false, | ||||
| 				) | ||||
| 			) | ||||
| 		))); | ||||
| 		)); | ||||
| 		$this->Task->interactive = false; | ||||
| 
 | ||||
| 		$result = $this->Task->doValidation($Model); | ||||
| 		$expected = array( | ||||
| 			'name' => array( | ||||
| 				'notempty' => 'notempty' | ||||
| 				'notBlank' => 'notBlank' | ||||
| 			), | ||||
| 			'email' => array( | ||||
| 				'email' => 'email', | ||||
|  | @ -622,6 +719,20 @@ class ModelTaskTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test non interactive doActsAs | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDoActsAs() { | ||||
| 		$this->Task->connection = 'test'; | ||||
| 		$this->Task->interactive = false; | ||||
| 		$model = new Model(array('ds' => 'test', 'name' => 'NumberTree')); | ||||
| 		$result = $this->Task->doActsAs($model); | ||||
| 
 | ||||
| 		$this->assertEquals(array('Tree'), $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Ensure that the fixture object is correctly called. | ||||
|  * | ||||
|  | @ -727,7 +838,7 @@ class ModelTaskTest extends CakeTestCase { | |||
| 	public function testBakeValidation() { | ||||
| 		$validate = array( | ||||
| 			'name' => array( | ||||
| 				'notempty' => 'notempty' | ||||
| 				'notBlank' => 'notBlank' | ||||
| 			), | ||||
| 			'email' => array( | ||||
| 				'email' => 'email', | ||||
|  | @ -744,8 +855,8 @@ class ModelTaskTest extends CakeTestCase { | |||
| 		$this->assertRegExp('/\$validate \= array\(/', $result); | ||||
| 		$expected = <<< STRINGEND | ||||
| array( | ||||
| 			'notempty' => array( | ||||
| 				'rule' => array('notempty'), | ||||
| 			'notBlank' => array( | ||||
| 				'rule' => array('notBlank'), | ||||
| 				//'message' => 'Your custom message here',
 | ||||
| 				//'allowEmpty' => false,
 | ||||
| 				//'required' => false,
 | ||||
|  | @ -835,6 +946,27 @@ STRINGEND; | |||
| 		$this->assertEquals(count(ClassRegistry::mapKeys()), 0); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test bake() for models with behaviors | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testBakeWithBehaviors() { | ||||
| 		$result = $this->Task->bake('NumberTree', array('actsAs' => array('Tree', 'PluginName.Sluggable'))); | ||||
| 		$expected = <<<TEXT | ||||
| /** | ||||
|  * Behaviors | ||||
|  * | ||||
|  * @var array | ||||
|  */ | ||||
| 	public \$actsAs = array( | ||||
| 		'Tree', | ||||
| 		'PluginName.Sluggable', | ||||
| 	); | ||||
| TEXT; | ||||
| 		$this->assertTextContains($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that execute passes runs bake depending with named model. | ||||
|  * | ||||
|  | @ -920,8 +1052,8 @@ STRINGEND; | |||
| 		$this->Task->args = array('all'); | ||||
| 		$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); | ||||
| 
 | ||||
| 		$this->Task->Fixture->expects($this->exactly(5))->method('bake'); | ||||
| 		$this->Task->Test->expects($this->exactly(5))->method('bake'); | ||||
| 		$this->Task->Fixture->expects($this->exactly(6))->method('bake'); | ||||
| 		$this->Task->Test->expects($this->exactly(6))->method('bake'); | ||||
| 
 | ||||
| 		$filename = '/my/path/BakeArticle.php'; | ||||
| 		$this->Task->expects($this->at(1))->method('createFile') | ||||
|  | @ -951,6 +1083,10 @@ STRINGEND; | |||
| 		$this->Task->expects($this->at(5))->method('createFile') | ||||
| 			->with($filename, $this->stringContains('class CategoryThread')); | ||||
| 
 | ||||
| 		$filename = '/my/path/NumberTree.php'; | ||||
| 		$this->Task->expects($this->at(6))->method('createFile') | ||||
| 			->with($filename, $this->stringContains('class NumberTree')); | ||||
| 
 | ||||
| 		$this->Task->execute(); | ||||
| 
 | ||||
| 		$this->assertEquals(count(ClassRegistry::keys()), 0); | ||||
|  | @ -958,7 +1094,7 @@ STRINGEND; | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that odd tablenames arent inflected back from modelname | ||||
|  * test that odd tablenames aren't inflected back from modelname | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -986,7 +1122,7 @@ STRINGEND; | |||
| 		$out = $this->getMock('ConsoleOutput', array(), array(), '', false); | ||||
| 		$in = $this->getMock('ConsoleInput', array(), array(), '', false); | ||||
| 		$this->Task = $this->getMock('ModelTask', | ||||
| 			array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'createFile'), | ||||
| 			array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'), | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 		$this->_setupOtherMocks(); | ||||
|  | @ -1000,6 +1136,7 @@ STRINGEND; | |||
| 		$this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object)); | ||||
| 		$this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array())); | ||||
| 		$this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array())); | ||||
| 		$this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue(array())); | ||||
| 
 | ||||
| 		$filename = '/my/path/BakeOdd.php'; | ||||
| 		$this->Task->expects($this->once())->method('createFile') | ||||
|  | @ -1013,7 +1150,7 @@ STRINGEND; | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that odd tablenames arent inflected back from modelname | ||||
|  * test that odd tablenames aren't inflected back from modelname | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -1041,7 +1178,7 @@ STRINGEND; | |||
| 		$out = $this->getMock('ConsoleOutput', array(), array(), '', false); | ||||
| 		$in = $this->getMock('ConsoleInput', array(), array(), '', false); | ||||
| 		$this->Task = $this->getMock('ModelTask', | ||||
| 			array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'createFile'), | ||||
| 			array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'), | ||||
| 			array($out, $out, $in) | ||||
| 		); | ||||
| 		$this->_setupOtherMocks(); | ||||
|  | @ -1055,6 +1192,7 @@ STRINGEND; | |||
| 		$this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object)); | ||||
| 		$this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array())); | ||||
| 		$this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array())); | ||||
| 		$this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue(array())); | ||||
| 
 | ||||
| 		$filename = '/my/path/BakeOdd.php'; | ||||
| 		$this->Task->expects($this->once())->method('createFile') | ||||
|  | @ -1082,7 +1220,7 @@ STRINGEND; | |||
| 		$this->Task->path = '/my/path/'; | ||||
| 		$this->Task->args = array('all'); | ||||
| 		$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); | ||||
| 		$this->Task->skipTables = array('bake_tags'); | ||||
| 		$this->Task->skipTables = array('bake_tags', 'number_trees'); | ||||
| 
 | ||||
| 		$this->Task->Fixture->expects($this->exactly(4))->method('bake'); | ||||
| 		$this->Task->Test->expects($this->exactly(4))->method('bake'); | ||||
|  |  | |||
|  | @ -4,19 +4,18 @@ | |||
|  * | ||||
|  * Test Case for plugin generation shell task | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @since         CakePHP v 1.3.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('ShellDispatcher', 'Console'); | ||||
|  | @ -59,7 +58,7 @@ class PluginTaskTest extends CakeTestCase { | |||
| 				array_splice($paths, $i, 1); | ||||
| 			} | ||||
| 		} | ||||
| 		$this->_testPath = array_push($paths, TMP . 'tests' . DS); | ||||
| 		$this->_testPath = array_push($paths, TMP . 'tests' . DS) - 1; | ||||
| 		App::build(array('plugins' => $paths)); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -81,17 +80,23 @@ class PluginTaskTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testBakeFoldersAndFiles() { | ||||
| 		$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath)); | ||||
| 		$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y')); | ||||
| 		$this->Task->expects($this->at(0)) | ||||
| 			->method('in') | ||||
| 			->will($this->returnValue($this->_testPath)); | ||||
| 		$this->Task->expects($this->at(1)) | ||||
| 			->method('in') | ||||
| 			->will($this->returnValue('y')); | ||||
| 
 | ||||
| 		$path = $this->Task->path . 'BakeTestPlugin'; | ||||
| 
 | ||||
| 		$file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php'; | ||||
| 		$this->Task->expects($this->at(2))->method('createFile') | ||||
| 		$this->Task->expects($this->at(2)) | ||||
| 			->method('createFile') | ||||
| 			->with($file, new PHPUnit_Framework_Constraint_IsAnything()); | ||||
| 
 | ||||
| 		$file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php'; | ||||
| 		$this->Task->expects($this->at(3))->method('createFile') | ||||
| 		$this->Task->expects($this->at(3)) | ||||
| 			->method('createFile') | ||||
| 			->with($file, new PHPUnit_Framework_Constraint_IsAnything()); | ||||
| 
 | ||||
| 		$this->Task->bake('BakeTestPlugin'); | ||||
|  | @ -101,18 +106,25 @@ class PluginTaskTest extends CakeTestCase { | |||
| 
 | ||||
| 		$directories = array( | ||||
| 			'Config' . DS . 'Schema', | ||||
| 			'Model' . DS . 'Behavior', | ||||
| 			'Model' . DS . 'Datasource', | ||||
| 			'Console' . DS . 'Command' . DS . 'Task', | ||||
| 			'Console' . DS . 'Templates', | ||||
| 			'Controller' . DS . 'Component', | ||||
| 			'Lib', | ||||
| 			'View' . DS . 'Helper', | ||||
| 			'Locale' . DS . 'eng' . DS . 'LC_MESSAGES', | ||||
| 			'Model' . DS . 'Behavior', | ||||
| 			'Model' . DS . 'Datasource', | ||||
| 			'Test' . DS . 'Case' . DS . 'Controller' . DS . 'Component', | ||||
| 			'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper', | ||||
| 			'Test' . DS . 'Case' . DS . 'Lib', | ||||
| 			'Test' . DS . 'Case' . DS . 'Model' . DS . 'Behavior', | ||||
| 			'Test' . DS . 'Case' . DS . 'Model' . DS . 'Datasource', | ||||
| 			'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper', | ||||
| 			'Test' . DS . 'Fixture', | ||||
| 			'Vendor', | ||||
| 			'webroot' | ||||
| 			'View' . DS . 'Elements', | ||||
| 			'View' . DS . 'Helper', | ||||
| 			'View' . DS . 'Layouts', | ||||
| 			'webroot' . DS . 'css', | ||||
| 			'webroot' . DS . 'js', | ||||
| 			'webroot' . DS . 'img', | ||||
| 		); | ||||
| 		foreach ($directories as $dir) { | ||||
| 			$this->assertTrue(is_dir($path . DS . $dir), 'Missing directory for ' . $dir); | ||||
|  | @ -186,7 +198,9 @@ class PluginTaskTest extends CakeTestCase { | |||
| 	public function testFindPathNonExistant() { | ||||
| 		$paths = App::path('plugins'); | ||||
| 		$last = count($paths); | ||||
| 		$paths[] = '/fake/path'; | ||||
| 
 | ||||
| 		array_unshift($paths, '/fake/path'); | ||||
| 		$paths[] = '/fake/path2'; | ||||
| 
 | ||||
| 		$this->Task = $this->getMock('PluginTask', | ||||
| 			array('in', 'out', 'err', 'createFile', '_stop'), | ||||
|  |  | |||
|  | @ -4,19 +4,18 @@ | |||
|  * | ||||
|  * Test Case for project generation shell task | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @since         CakePHP v 1.3.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('ShellDispatcher', 'Console'); | ||||
|  | @ -150,7 +149,7 @@ class ProjectTaskTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test bake with CakePHP on the include path.  The constants should remain commented out. | ||||
|  * test bake with CakePHP on the include path. The constants should remain commented out. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -198,7 +197,6 @@ class ProjectTaskTest extends CakeTestCase { | |||
| 			'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' => 'empty', | ||||
| 			'Test' . DS . 'Fixture' => 'empty', | ||||
| 			'Vendor' => 'empty', | ||||
| 			'View' . DS . 'Elements' => 'empty', | ||||
| 			'View' . DS . 'Scaffolds' => 'empty', | ||||
| 			'tmp' . DS . 'cache' . DS . 'models' => 'empty', | ||||
| 			'tmp' . DS . 'cache' . DS . 'persistent' => 'empty', | ||||
|  | @ -249,6 +247,24 @@ class ProjectTaskTest extends CakeTestCase { | |||
| 		$this->assertNotRegExp('/76859309657453542496749683645/', $contents, 'Default CipherSeed left behind. %s'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test generation of cache prefix | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCachePrefixGeneration() { | ||||
| 		$this->_setupTestProject(); | ||||
| 
 | ||||
| 		$path = $this->Task->path . 'bake_test_app' . DS; | ||||
| 		$result = $this->Task->cachePrefix($path); | ||||
| 		$this->assertTrue($result); | ||||
| 
 | ||||
| 		$File = new File($path . 'Config' . DS . 'core.php'); | ||||
| 		$contents = $File->read(); | ||||
| 		$this->assertRegExp('/\$prefix = \'.+\';/', $contents, '$prefix is not defined'); | ||||
| 		$this->assertNotRegExp('/\$prefix = \'myapp_\';/', $contents, 'Default cache prefix left behind. %s'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that index.php is generated correctly. | ||||
|  * | ||||
|  |  | |||
|  | @ -4,21 +4,20 @@ | |||
|  * | ||||
|  * Test Case for TemplateTask generation shell task | ||||
|  * | ||||
|  * | ||||
|  * 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('ShellDispatcher', 'Console'); | ||||
| App::uses('ConsoleOutput', 'Console'); | ||||
| App::uses('ConsoleInput', 'Console'); | ||||
|  | @ -93,8 +92,8 @@ class TemplateTaskTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test getting the correct theme name.  Ensure that with only one theme, or a theme param | ||||
|  * that the user is not bugged.  If there are more, find and return the correct theme name | ||||
|  * test getting the correct theme name. Ensure that with only one theme, or a theme param | ||||
|  * that the user is not bugged. If there are more, find and return the correct theme name | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  |  | |||
|  | @ -4,19 +4,18 @@ | |||
|  * | ||||
|  * Test Case for test generation shell task | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP :  Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @since         CakePHP v 1.2.0.7726 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('ShellDispatcher', 'Console'); | ||||
|  | @ -32,17 +31,9 @@ App::uses('Model', 'Model'); | |||
|  * Test Article model | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class TestTaskArticle extends Model { | ||||
| 
 | ||||
| /** | ||||
|  * Model name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'TestTaskArticle'; | ||||
| 
 | ||||
| /** | ||||
|  * Table name to use | ||||
|  * | ||||
|  | @ -106,17 +97,9 @@ class TestTaskArticle extends Model { | |||
|  * Tag Testing Model | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class TestTaskTag extends Model { | ||||
| 
 | ||||
| /** | ||||
|  * Model name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'TestTaskTag'; | ||||
| 
 | ||||
| /** | ||||
|  * Table name | ||||
|  * | ||||
|  | @ -143,7 +126,6 @@ class TestTaskTag extends Model { | |||
|  * Simulated plugin | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class TestTaskAppModel extends Model { | ||||
| } | ||||
|  | @ -152,17 +134,9 @@ class TestTaskAppModel extends Model { | |||
|  * Testing AppMode (TaskComment) | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class TestTaskComment extends TestTaskAppModel { | ||||
| 
 | ||||
| /** | ||||
|  * Model name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'TestTaskComment'; | ||||
| 
 | ||||
| /** | ||||
|  * Table name | ||||
|  * | ||||
|  | @ -187,17 +161,9 @@ class TestTaskComment extends TestTaskAppModel { | |||
|  * Test Task Comments Controller | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class TestTaskCommentsController extends Controller { | ||||
| 
 | ||||
| /** | ||||
|  * Controller Name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'TestTaskComments'; | ||||
| 
 | ||||
| /** | ||||
|  * Models to use | ||||
|  * | ||||
|  | @ -349,14 +315,14 @@ class TestTaskTest extends CakeTestCase { | |||
| 		)); | ||||
| 		$keys = ClassRegistry::keys(); | ||||
| 		$this->assertTrue(in_array('test_task_comment', $keys)); | ||||
| 		$object = $this->Task->buildTestSubject('Model', 'TestTaskComment'); | ||||
| 		$this->Task->buildTestSubject('Model', 'TestTaskComment'); | ||||
| 
 | ||||
| 		$keys = ClassRegistry::keys(); | ||||
| 		$this->assertFalse(in_array('random', $keys)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that getClassName returns the user choice as a classname. | ||||
|  * test that getClassName returns the user choice as a class name. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -391,7 +357,7 @@ class TestTaskTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that resolving classnames works | ||||
|  * test that resolving class names works | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -425,8 +391,8 @@ class TestTaskTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test baking files.  The conditionally run tests are known to fail in PHP4 | ||||
|  * as PHP4 classnames are all lower case, breaking the plugin path inflection. | ||||
|  * test baking files. The conditionally run tests are known to fail in PHP4 | ||||
|  * as PHP4 class names are all lower case, breaking the plugin path inflection. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -447,6 +413,8 @@ class TestTaskTest extends CakeTestCase { | |||
| 
 | ||||
| 		$this->assertContains('function testDoSomething()', $result); | ||||
| 		$this->assertContains('function testDoSomethingElse()', $result); | ||||
| 		$this->assertContains('$this->markTestIncomplete(\'testDoSomething not implemented.\')', $result); | ||||
| 		$this->assertContains('$this->markTestIncomplete(\'testDoSomethingElse not implemented.\')', $result); | ||||
| 
 | ||||
| 		$this->assertContains("'app.test_task_article'", $result); | ||||
| 		$this->assertContains("'app.test_task_comment'", $result); | ||||
|  | @ -566,6 +534,8 @@ class TestTaskTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Test generateUses() | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGenerateUses() { | ||||
| 		$result = $this->Task->generateUses('model', 'Model', 'Post'); | ||||
|  | @ -694,7 +664,7 @@ class TestTaskTest extends CakeTestCase { | |||
| 	public function testTestCaseFileNamePlugin() { | ||||
| 		$this->Task->path = DS . 'my' . DS . 'path' . DS . 'tests' . DS; | ||||
| 
 | ||||
| 		CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS )); | ||||
| 		CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS)); | ||||
| 		$this->Task->plugin = 'TestTest'; | ||||
| 		$result = $this->Task->testCaseFileName('Model', 'Post'); | ||||
| 		$expected = APP . 'Plugin' . DS . 'TestTest' . DS . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'PostTest.php'; | ||||
|  |  | |||
|  | @ -4,19 +4,18 @@ | |||
|  * | ||||
|  * Test Case for view generation shell task | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @since         CakePHP v 1.2.0.7726 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('ShellDispatcher', 'Console'); | ||||
|  | @ -30,22 +29,15 @@ App::uses('ProjectTask', 'Console/Command/Task'); | |||
| App::uses('DbConfigTask', 'Console/Command/Task'); | ||||
| App::uses('Model', 'Model'); | ||||
| App::uses('Controller', 'Controller'); | ||||
| App::uses('AppController', 'Controller'); | ||||
| 
 | ||||
| /** | ||||
|  * Test View Task Comment Model | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class ViewTaskComment extends Model { | ||||
| 
 | ||||
| /** | ||||
|  * Model name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'ViewTaskComment'; | ||||
| 
 | ||||
| /** | ||||
|  * Table name | ||||
|  * | ||||
|  | @ -70,17 +62,9 @@ class ViewTaskComment extends Model { | |||
|  * Test View Task Article Model | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class ViewTaskArticle extends Model { | ||||
| 
 | ||||
| /** | ||||
|  * Model name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'ViewTaskArticle'; | ||||
| 
 | ||||
| /** | ||||
|  * Table name | ||||
|  * | ||||
|  | @ -93,17 +77,9 @@ class ViewTaskArticle extends Model { | |||
|  * Test View Task Comments Controller | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class ViewTaskCommentsController extends Controller { | ||||
| 
 | ||||
| /** | ||||
|  * Controller name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'ViewTaskComments'; | ||||
| 
 | ||||
| /** | ||||
|  * Testing public controller action | ||||
|  * | ||||
|  | @ -126,17 +102,9 @@ class ViewTaskCommentsController extends Controller { | |||
|  * Test View Task Articles Controller | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  * @package       Cake.Test.Case.Console.Command.Task | ||||
|  */ | ||||
| class ViewTaskArticlesController extends Controller { | ||||
| 
 | ||||
| /** | ||||
|  * Controller name | ||||
|  * | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'ViewTaskArticles'; | ||||
| 
 | ||||
| /** | ||||
|  * Test public controller action | ||||
|  * | ||||
|  | @ -355,10 +323,11 @@ class ViewTaskTest extends CakeTestCase { | |||
| 	public function testBakeIndex() { | ||||
| 		$this->Task->controllerName = 'ViewTaskComments'; | ||||
| 
 | ||||
| 		$expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'View' . DS . 'index.ctp'); | ||||
| 		$this->Task->expects($this->at(0))->method('createFile') | ||||
| 			->with( | ||||
| 				TMP . 'ViewTaskComments' . DS . 'index.ctp', | ||||
| 				$this->stringContains("\$viewTaskComment['Article']['title']") | ||||
| 				$expected | ||||
| 			); | ||||
| 		$this->Task->bake('index', true); | ||||
| 	} | ||||
|  |  | |||
|  | @ -2,24 +2,28 @@ | |||
| /** | ||||
|  * TestSuiteShell 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 | ||||
|  * @since         CakePHP(tm) v 2.0 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('ShellDispatcher', 'Console'); | ||||
| App::uses('TestShell', 'Console/Command'); | ||||
| 
 | ||||
| /** | ||||
|  * TestTestShell | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  */ | ||||
| class TestTestShell extends TestShell { | ||||
| 
 | ||||
| 	public function mapFileToCase($file, $category, $throwOnMissingFile = true) { | ||||
|  | @ -32,6 +36,11 @@ class TestTestShell extends TestShell { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * TestShellTest | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Console.Command | ||||
|  */ | ||||
| class TestShellTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  | @ -332,4 +341,40 @@ class TestShellTest extends CakeTestCase { | |||
| 			); | ||||
| 		$this->Shell->main(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests that the 'quiet' parameter gets swallowed before calling PHPUnit | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRunnerOptionsQuiet() { | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->args = array('core', 'Basics'); | ||||
| 		$this->Shell->params = array('quiet' => true); | ||||
| 
 | ||||
| 		$this->Shell->expects($this->once())->method('_run') | ||||
| 			->with( | ||||
| 				array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'), | ||||
| 				array('--colors') | ||||
| 			); | ||||
| 		$this->Shell->main(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests that the '--directive' parameter change to '-d' before calling PHPUnit | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRunnerOptionsDirective() { | ||||
| 		$this->Shell->startup(); | ||||
| 		$this->Shell->args = array('core', 'Basics'); | ||||
| 		$this->Shell->params = array('directive' => 'memory_limit=128M'); | ||||
| 
 | ||||
| 		$this->Shell->expects($this->once())->method('_run') | ||||
| 			->with( | ||||
| 				array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'), | ||||
| 				array('-d', 'memory_limit=128M', '--colors') | ||||
| 			); | ||||
| 		$this->Shell->main(); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko