浏览代码

adding missing app uses statements

euromark 13 年之前
父节点
当前提交
ada4dad238
共有 43 个文件被更改,包括 18346 次插入114 次删除
  1. 1 1
      Console/Command/CcShell.php
  2. 1 0
      Console/Command/PhpTagShell.php
  3. 2 3
      Console/Command/WhitespaceShell.php
  4. 4 29
      Controller/Component/AuthExtComponent.php
  5. 1 0
      Controller/TinyUrlsController.php
  6. 1 0
      Controller/ToolsAppController.php
  7. 0 2
      Lib/Bootstrap/MyBootstrap.php
  8. 35 0
      Lib/Error/MyErrorHandler.php
  9. 23 0
      Lib/Error/MyExceptionRenderer.php
  10. 1 0
      Model/Behavior/BitmaskedBehavior.php
  11. 2 0
      Model/Behavior/CaptchaBehavior.php
  12. 1 0
      Model/Behavior/ChangePasswordBehavior.php
  13. 1 0
      Model/Behavior/ConfirmableBehavior.php
  14. 1 0
      Model/Behavior/DecimalInputBehavior.php
  15. 1 0
      Model/Behavior/GeocoderBehavior.php
  16. 3 1
      Model/Behavior/JsonableBehavior.php
  17. 6 2
      Model/Behavior/LogableBehavior.php
  18. 2 0
      Model/Behavior/MasterPasswordBehavior.php
  19. 7 5
      Model/Behavior/SluggedBehavior.php
  20. 1 0
      Model/Behavior/TypographicBehavior.php
  21. 1 0
      Model/Behavior/WhoDidItBehavior.php
  22. 1 0
      Model/ToolsAppModel.php
  23. 10 1
      Test/Case/Lib/AuthTest.php
  24. 1 1
      Test/Case/Model/Behavior/BitmaskedBehaviorTest.php
  25. 5 4
      Test/Case/Model/Behavior/DecimalInputBehaviorTest.php
  26. 23 23
      Test/Case/Model/Behavior/JsonableBehaviorTest.php
  27. 34 18
      Test/Case/Model/Behavior/LinkableBehaviorTest.php
  28. 2 2
      Test/Case/Model/Behavior/MasterPasswordBehaviorTest.php
  29. 18151 9
      Test/Case/Model/Behavior/SluggedBehaviorTest.php
  30. 5 7
      Test/Case/Model/Behavior/TypographicBehaviorTest.php
  31. 6 5
      Test/Fixture/UserFixture.php
  32. 1 0
      View/Helper/BootstrapHelper.php
  33. 1 0
      View/Helper/CaptchaHelper.php
  34. 1 0
      View/Helper/CommonHelper.php
  35. 1 0
      View/Helper/FlattrHelper.php
  36. 1 0
      View/Helper/FormatHelper.php
  37. 1 0
      View/Helper/GravatarHelper.php
  38. 1 0
      View/Helper/HcardHelper.php
  39. 1 0
      View/Helper/IcalHelper.php
  40. 1 0
      View/Helper/LoremHelper.php
  41. 1 0
      View/Helper/PhpThumbHelper.php
  42. 1 0
      View/Helper/QrCodeHelper.php
  43. 2 1
      View/Helper/TreeHelper.php

+ 1 - 1
Console/Command/CcShell.php

@@ -1,5 +1,5 @@
 <?php
-
+App::uses('AppShell', 'Console/Command');
 App::uses('Folder', 'Utility');
 App::uses('File', 'Utility');
 

+ 1 - 0
Console/Command/PhpTagShell.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppShell', 'Console/Command');
 App::uses('Folder', 'Utility');
 
 /**

+ 2 - 3
Console/Command/WhitespaceShell.php

@@ -1,9 +1,8 @@
 <?php
-App::import('Core',array('Folder'));
+App::uses('AppShell', 'Console/Command');
+App::uses('Folder', 'Utility');
 
 class WhitespaceShell extends AppShell {
-	public $tasks = array();
-	public $uses = array();
 
 	public $autoCorrectAll = false;
 	# each report: [0] => found, [1] => corrected

+ 4 - 29
Controller/Component/AuthExtComponent.php

@@ -57,34 +57,10 @@ class AuthExtComponent extends AuthComponent {
 
 
 	public function __construct(ComponentCollection $Collection, $settings = array()) {
-		$settings = array_merge($this->settings, (array)$settings, (array)Configure::read('Auth'));
-		$this->Controller = $Collection->getController();
+		$settings = array_merge($this->settings, (array)Configure::read('Auth'), (array)$settings);
+		//$this->Controller = $Collection->getController();
+		
 		parent::__construct($Collection, $settings);
-
-		# auto-select multi if necessary
-		if ($this->settings['multi'] === null) {
-			$Model = $this->getModel();
-			if (!empty($Model->hasMany)) {
-				foreach ($Model->hasMany as $name => $relation) {
-					if ($name != $this->roleModel) {
-						continue;
-					}
-					$this->settings['multi'] = false;
-					return;
-				}
-			}
-			$Model = $this->getModel();
-			if (!empty($Model->hasAndBelongsToMany)) {
-				foreach ($Model->hasAndBelongsToMany as $name => $relation) {
-					if ($name != $this->roleModel) {
-						continue;
-					}
-					$this->settings['multi'] = true;
-					return;
-				}
-			}
-			//$this->log('AuthExt component not configured properly (auto select multi failed)');
-		}
 	}
 
 	public function initialize(Controller $Controller) {
@@ -216,7 +192,6 @@ class AuthExtComponent extends AuthComponent {
 				$this->{$withModel} = ClassRegistry::init($with);
 			}
 			# only for multi
-
 			if ($this->settings['multi'] || !isset($completeAuth[$this->settings['userModel']]['role_id'])) {
 				$parentModelAlias = $this->settings['parentModelAlias'];
 				$completeAuth[$this->settings['userModel']][$parentModelAlias] = array(); # default: no roles!
@@ -229,7 +204,6 @@ class AuthExtComponent extends AuthComponent {
 					//$roles = set::extract('/'.$with.'['.$this->fieldKey.'!='.$primaryRole.']/'.$this->fieldKey, $roles);
 
 					// add the suplemental roles id under the Auth session key
-
 					$completeAuth[$this->settings['userModel']][$parentModelAlias] = $roles; // or USER_ROLE_KEY
 					//pr($completeAuth);
 				}
@@ -286,6 +260,7 @@ class AuthExtComponent extends AuthComponent {
 	 * @return boolean
 	 */
 	public function startup(Controller $controller) {
+		//parent::startup($controller);
 		if ($controller->name == 'CakeError') {
 			return true;
 		}

+ 1 - 0
Controller/TinyUrlsController.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('ToolsAppController', 'Tools.Controller');
 /*
 
 Apply this route (/Config/routes.php):

+ 1 - 0
Controller/ToolsAppController.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppController', 'Controller');
 
 class ToolsAppController extends AppController {
 

+ 0 - 2
Lib/Bootstrap/MyBootstrap.php

@@ -532,8 +532,6 @@ function uid($default = null) {
 
 
 
-register_shutdown_function('shutdownFunction');
-
 /**
  * own shutdown function - also logs fatal errors (necessary until cake2.2)
  * 2010-10-17 ms

+ 35 - 0
Lib/Error/MyErrorHandler.php

@@ -88,6 +88,41 @@ class MyErrorHandler extends ErrorHandler {
 	}
 
 	/**
+	 * Generate an error page when some fatal error happens.
+	 *
+	 * @param integer $code Code of error
+	 * @param string $description Error description
+	 * @param string $file File on which error occurred
+	 * @param integer $line Line that triggered the error
+	 * @return boolean
+	 */
+	public static function handleFatalError($code, $description, $file, $line) {
+		$logMessage = 'Fatal Error (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
+		CakeLog::write(LOG_ERR, $logMessage);
+
+		$exceptionHandler = Configure::read('Exception.handler');
+		if (!is_callable($exceptionHandler)) {
+			return false;
+		}
+
+		# cake bug? temporary!
+		if (Configure::read('debug')) {
+			return false;
+		}
+
+		if (ob_get_level()) {
+			ob_clean();
+		}
+
+		if (Configure::read('debug')) {
+			call_user_func($exceptionHandler, new FatalErrorException($description, 500, $file, $line));
+		} else {
+			call_user_func($exceptionHandler, new InternalErrorException());
+		}
+		return false;
+	}
+
+	/**
 	 * append some more infos to better track down the error
 	 * @return string
 	 * 2011-12-21 ms

+ 23 - 0
Lib/Error/MyExceptionRenderer.php

@@ -3,4 +3,27 @@ App::uses('ExceptionRenderer', 'Error');
 
 class MyExceptionRenderer extends ExceptionRenderer {
 
+	/**
+	 * A safer way to render error messages, replaces all helpers, with basics
+	 * and doesn't call component methods.
+	 *
+	 * @param string $template The template to render
+	 * @return void
+	 */
+	protected function _outputMessageSafe($template) {
+		$this->controller->layoutPath = null;
+		$this->controller->subDir = null;
+		$this->controller->viewPath = 'Errors/';
+		$this->controller->viewClass = 'View';
+		$this->controller->layout = 'error';
+		$this->controller->helpers = array('Form', 'Html', 'Session');
+
+		$this->controller->render($template);
+		$this->controller->response->type('html');
+		
+		$x = $this->controller->response->body(); $this->controller->response->body(h($x));
+		
+		$this->controller->response->send();
+	}
+	
 }

+ 1 - 0
Model/Behavior/BitmaskedBehavior.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('ModelBehavior', 'Model');
 
 /**
  * BitmaskedBehavior

+ 2 - 0
Model/Behavior/CaptchaBehavior.php

@@ -3,7 +3,9 @@
 define('CAPTCHA_MIN_TIME', 3); # seconds the form will need to be filled in by a human
 define('CAPTCHA_MAX_TIME', HOUR);	# seconds the form will need to be submitted in
 
+App::uses('ModelBehavior', 'Model');
 App::uses('CaptchaLib', 'Tools.Lib');
+App::uses('CommonComponent', 'Tools.Controller/Component');
 
 /**
  * CaptchaBehavior

+ 1 - 0
Model/Behavior/ChangePasswordBehavior.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('ModelBehavior', 'Model');
 App::uses('CakeResponse', 'Network');
 App::uses('Security', 'Utility');
 

+ 1 - 0
Model/Behavior/ConfirmableBehavior.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('ModelBehavior', 'Model/Behavior');
 /**
  * ConfirmableBehavior allows forms to easily require a checkbox toggled (confirmed)
  * example: terms of use on registration

+ 1 - 0
Model/Behavior/DecimalInputBehavior.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('ModelBehavior', 'Model/Behavior');
 /**
  * //ALREADY exists as number_format in a slightly different way!
  *

+ 1 - 0
Model/Behavior/GeocoderBehavior.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('ModelBehavior', 'Model/Behavior');
 App::uses('GeocodeLib', 'Tools.Lib');
 
 /**

+ 3 - 1
Model/Behavior/JsonableBehavior.php

@@ -1,4 +1,6 @@
 <?php
+App::uses('ModelBehavior', 'Model');
+
 /**
  * Copyright 2011, PJ Hile (http://www.pjhile.com)
  *
@@ -53,7 +55,7 @@ class JsonableBehavior extends ModelBehavior {
 	);
 
 	public function setup(Model $Model, $config = array()) {
-		$this->settings[$Model->alias] = Set::merge($this->_defaultSettings, $config);
+  $this->settings[$Model->alias] = Set::merge($this->_defaultSettings, $config);
 		//extract ($this->settings[$Model->alias]);
 		if (!is_array($this->settings[$Model->alias]['fields'])) {
 			$this->settings[$Model->alias]['fields'] = (array)$this->settings[$Model->alias]['fields'];

+ 6 - 2
Model/Behavior/LogableBehavior.php

@@ -1,5 +1,6 @@
 <?php
 App::uses('CakeSession', 'Model/Datasource');
+App::uses('ModelBehavior', 'Model');
 
 if (!defined('CLASS_USER')) {
 	define('CLASS_USER', 'User');
@@ -161,6 +162,7 @@ class LogableBehavior extends ModelBehavior {
 			 'fields' => array(),
 			 'limit' => 50,
 		);
+
 		$params = array_merge($defaults, $params);
 		$options = array('order' => $params['order'], 'conditions' => $params['conditions'], 'fields' => $params['fields'], 'limit' => $params['limit']);
 		if ($params[$this->settings[$Model->alias]['classField']] === null) {
@@ -210,7 +212,7 @@ class LogableBehavior extends ModelBehavior {
 			$username = $this->user[$this->UserModel->alias][$this->UserModel->displayField];
 		} else {
 			$this->UserModel->recursive = -1;
-			$user = $this->UserModel->find(array($this->UserModel->primaryKey => $user_id));
+			$user = $this->UserModel->find('first', array('conditions'=>array($this->UserModel->primaryKey => $user_id)));
 			$username = $user[$this->UserModel->alias][$this->UserModel->displayField];
 		}
 		$fields = array();
@@ -375,7 +377,9 @@ class LogableBehavior extends ModelBehavior {
 	}
 
 	public function beforeSave(Model $Model) {
-		$this->setUserData($Model);
+		if ($this->user === null) {
+			$this->setUserData($Model);
+		}
 		if ($this->Log->hasField('change') && $Model->id) {
 			$this->old = $Model->find('first', array('conditions' => array($Model->primaryKey => $Model->id), 'recursive' => -1));
 		}

+ 2 - 0
Model/Behavior/MasterPasswordBehavior.php

@@ -1,4 +1,6 @@
 <?php
+App::uses('ModelBehavior', 'Model');
+
 /**
  * MasterPassword Behavior for admin views
  *

+ 7 - 5
Model/Behavior/SluggedBehavior.php

@@ -22,9 +22,10 @@
 /**
  * Ensure that mb_ functions exist
  */
-App::uses('Multibyte', 'I18n');
+App::import('I18n', 'Multibyte');
 App::uses('ModelBehavior', 'Model');
 
+
 /**
  * SluggedBehavior class
  *
@@ -272,14 +273,15 @@ class SluggedBehavior extends ModelBehavior {
 		$return = 'array';
 		$originalIfEmpty = true;
 		extract($params);
-
+		/*
 		if (!class_exists('MiCache')) {
 			App::import('Vendor', 'Mi.MiCache');
 		}
+		*/
 		if (!empty($this->settings[$Model->alias]['language'])) {
 			$lang = $this->settings[$Model->alias]['language'];
 		} else {
-			$lang = MiCache::setting('Site.lang');
+			$lang = Configure::read('Site.lang');
 			if (!$lang) {
 				$lang = 'eng';
 			}
@@ -288,8 +290,8 @@ class SluggedBehavior extends ModelBehavior {
 
 		if (!array_key_exists($lang, $this->stopWords)) {
 			ob_start();
-			if (!App::import('Vendor', 'stop_words/' . $lang, array('file' => "stop_words/$lang.txt"))) {
-				App::import('Vendor', 'stop_words/' . $lang, array('plugin' => 'Mi', 'file' => "stop_words/$lang.txt"));
+			if (!App::import('Vendor', 'stop_words_' . $lang, array('file' => "stop_words".DS."$lang.txt"))) {
+				$res = App::import('Vendor', 'Tools.stop_words_' . $lang, array('file' => "stop_words".DS."$lang.txt"));
 			}
 			$stopWords = preg_replace('@/\*.*\*/@', '', ob_get_clean());
 			$this->stopWords[$lang] = array_filter(array_map('trim', explode("\n", $stopWords)));

+ 1 - 0
Model/Behavior/TypographicBehavior.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('ModelBehavior', 'Model');
 
 /**
  * “smart quotes” become "dumb quotes" on save

+ 1 - 0
Model/Behavior/WhoDidItBehavior.php

@@ -1,5 +1,6 @@
 <?php
 App::uses('CakeSession', 'Model/Datasource');
+App::uses('ModelBehavior', 'Model');
 
 /**
  * WhoDidIt Model Behavior for CakePHP

+ 1 - 0
Model/ToolsAppModel.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppModel', 'Model');
 
 class ToolsAppModel extends AppModel {
 

+ 10 - 1
Test/Case/Lib/AuthTest.php

@@ -1,5 +1,4 @@
 <?php
-
 App::uses('Auth', 'Tools.Lib');
 App::uses('MyCakeTestCase', 'Tools.Lib');
 
@@ -8,6 +7,16 @@ App::uses('MyCakeTestCase', 'Tools.Lib');
  */
 class AuthTest extends MyCakeTestCase {
 
+	public $fixtures = array('core.session');
+
+	public function startTest() {
+		ClassRegistry::init('Session');
+	}
+
+	public function endTest() {
+		ClassRegistry::flush();
+	}
+
 	public function testHasRole() {
 		$res = Auth::hasRole(1, array(2, 3, 6));
 		$this->assertFalse($res);

+ 1 - 1
Test/Case/Model/Behavior/BitmaskedBehaviorTest.php

@@ -1,7 +1,7 @@
 <?php
 
 App::import('Behavior', 'Tools.Bitmasked');
-App::uses('App', 'Core');
+App::uses('AppModel', 'Model');
 App::uses('MyCakeTestCase', 'Tools.Lib');
 App::uses('MyModel', 'Tools.Lib');
 

+ 5 - 4
Test/Case/Model/Behavior/DecimalInputBehaviorTest.php

@@ -1,7 +1,7 @@
 <?php
 
 App::import('Behavior', 'Tools.DecimalInput');
-App::uses('App', 'Core');
+App::uses('AppModel', 'Model');
 App::uses('MyCakeTestCase', 'Tools.Lib');
 
 
@@ -9,7 +9,7 @@ class DecimalInputBehaviorTest extends MyCakeTestCase {
 
 	public function startTest() {
 		//$this->Comment = ClassRegistry::init('Comment');
-		$this->Comment = new TestModel();
+		$this->Comment = new DecimalInputTestModel();
 		$this->Comment->Behaviors->attach('Tools.DecimalInput', array('fields'=>array('rel_rate', 'set_rate'), 'output'=>true));
 	}
 
@@ -88,11 +88,12 @@ class DecimalInputBehaviorTest extends MyCakeTestCase {
 
 /** other files **/
 
-class TestModel extends AppModel {
-
+class DecimalInputTestModel extends AppModel {
 
 	public $alias = 'TestModel';
+
 	public $useTable = false;
+	
 	public $displayField = 'title';
 
 	public function find($type = null, $options = array(), $customData = null) {

+ 23 - 23
Test/Case/Model/Behavior/JsonableBehaviorTest.php

@@ -1,22 +1,22 @@
 <?php
 
-App::import('Behavior', 'Tools.Jsonable');
-App::uses('App', 'Core');
+App::uses('JsonableBehavior', 'Tools.Model/Behavior');
+App::uses('AppModel', 'Model');
 App::uses('MyCakeTestCase', 'Tools.Lib');
 
 
 class JsonableBehaviorTest extends MyCakeTestCase {
-	/*
+
 	public $fixtures = array(
 		'core.comment'
 	);
-	*/
+
 	public $Comment;
 
 	public function startTest() {
 		//$this->Comment = ClassRegistry::init('Comment');
-		$this->Comment = new JsonableTestModel();
-		$this->Comment->Behaviors->attach('Jsonable', array());
+		$this->Comment = new JsonableBehaviorTestModel();
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array());
 	}
 
 /** INPUT **/
@@ -34,14 +34,14 @@ class JsonableBehaviorTest extends MyCakeTestCase {
 		$this->assertTrue($res);
 
 		$res = $this->Comment->data;
-		echo returns($res);
-		$this->assertSame($res['JsonableTestModel']['details'], '{"x":"y"}');
+		echo returns($res); ob_flush();
+		$this->assertSame($res['JsonableBehaviorTestModel']['details'], '{"x":"y"}');
 	}
 
 	public function testFieldsWithList() {
 		echo $this->_header(__FUNCTION__);
 		$this->Comment->Behaviors->detach('Jsonable');
-		$this->Comment->Behaviors->attach('Jsonable', array('fields'=>array('details'), 'input'=>'list'));
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array('fields'=>array('details'), 'input'=>'list'));
 
 		$data = array(
 			'comment' => 'blabla',
@@ -54,7 +54,7 @@ class JsonableBehaviorTest extends MyCakeTestCase {
 
 		$res = $this->Comment->data;
 		echo returns($res);
-		$this->assertSame($res['JsonableTestModel']['details'], '["z","y","x"]');
+		$this->assertSame($res['JsonableBehaviorTestModel']['details'], '["z","y","x"]');
 
 		# with sort and unique
 		$data = array(
@@ -64,20 +64,20 @@ class JsonableBehaviorTest extends MyCakeTestCase {
 			'details' => 'z|x|y|x',
 		);
 		$this->Comment->Behaviors->detach('Jsonable');
-		$this->Comment->Behaviors->attach('Jsonable', array('fields'=>array('details'), 'input'=>'list', 'sort'=>true));
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array('fields'=>array('details'), 'input'=>'list', 'sort'=>true));
 
 		$res = $this->Comment->save($data);
 		$this->assertTrue($res);
 
 		$res = $this->Comment->data;
 		echo returns($res);
-		$this->assertSame($res['JsonableTestModel']['details'], '["x","y","z"]');
+		$this->assertSame($res['JsonableBehaviorTestModel']['details'], '["x","y","z"]');
 	}
 
 	public function testFieldsWithParam() {
 		echo $this->_header(__FUNCTION__);
 		$this->Comment->Behaviors->detach('Jsonable');
-		$this->Comment->Behaviors->attach('Jsonable', array('fields'=>array('details'), 'input'=>'param'));
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array('fields'=>array('details'), 'input'=>'param'));
 
 		$data = array(
 			'comment' => 'blabla',
@@ -90,7 +90,7 @@ class JsonableBehaviorTest extends MyCakeTestCase {
 
 		$res = $this->Comment->data;
 		echo returns($res);
-		$this->assertSame($res['JsonableTestModel']['details'], '{"z":"vz","y":"yz","x":"xz"}');
+		$this->assertSame($res['JsonableBehaviorTestModel']['details'], '{"z":"vz","y":"yz","x":"xz"}');
 	}
 
 
@@ -100,26 +100,26 @@ class JsonableBehaviorTest extends MyCakeTestCase {
 	public function testFieldsOnFind() {
 		echo $this->_header(__FUNCTION__);
 		$this->Comment->Behaviors->detach('Jsonable');
-		$this->Comment->Behaviors->attach('Jsonable', array('fields'=>array('details')));
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array('fields'=>array('details')));
 
 		$res = $this->Comment->find('first', array());
 
-		$this->assertEquals($res['JsonableTestModel']['details'], array('x'=>'y'));
+		$this->assertEquals($res['JsonableBehaviorTestModel']['details'], array('x'=>'y'));
 		pr($res);
 
 
 		$this->Comment->Behaviors->detach('Jsonable');
-		$this->Comment->Behaviors->attach('Jsonable', array('output'=>'param', 'fields'=>array('details')));
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array('output'=>'param', 'fields'=>array('details')));
 
 		$res = $this->Comment->find('first', array());
 		pr($res);
-		$this->assertEquals($res['JsonableTestModel']['details'], 'x:y');
+		$this->assertEquals($res['JsonableBehaviorTestModel']['details'], 'x:y');
 
 
 
 
 		$this->Comment->Behaviors->detach('Jsonable');
-		$this->Comment->Behaviors->attach('Jsonable', array('output'=>'list', 'fields'=>array('details')));
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array('output'=>'list', 'fields'=>array('details')));
 
 		$data = array(
 			'comment' => 'blabla',
@@ -129,13 +129,13 @@ class JsonableBehaviorTest extends MyCakeTestCase {
 		);
 		$res = $this->Comment->find('first', array(), $data);
 		pr($res);
-		$this->assertEquals($res['JsonableTestModel']['details'], 'z|y|x');
+		$this->assertEquals($res['JsonableBehaviorTestModel']['details'], 'z|y|x');
 
 		echo BR.BR;
 
 
 		$this->Comment->Behaviors->detach('Jsonable');
-		$this->Comment->Behaviors->attach('Jsonable', array('output'=>'list', 'separator'=>', ', 'fields'=>array('details')));
+		$this->Comment->Behaviors->attach('Tools.Jsonable', array('output'=>'list', 'separator'=>', ', 'fields'=>array('details')));
 
 		$data = array(
 			'comment' => 'blabla',
@@ -145,14 +145,14 @@ class JsonableBehaviorTest extends MyCakeTestCase {
 		);
 		$res = $this->Comment->find('first', array(), $data);
 		pr($res);
-		$this->assertEquals($res['JsonableTestModel']['details'], 'z, y, x');
+		$this->assertEquals($res['JsonableBehaviorTestModel']['details'], 'z, y, x');
 
 
 		echo BR.BR;
 
 		$res = $this->Comment->find('all', array(), $data);
 		pr($res);
-		$this->assertEquals($res[0]['JsonableTestModel']['details'], 'z, y, x');
+		$this->assertEquals($res[0]['JsonableBehaviorTestModel']['details'], 'z, y, x');
 	}
 }
 

+ 34 - 18
Test/Case/Model/Behavior/LinkableBehaviorTest.php

@@ -40,8 +40,11 @@ class LinkableBehaviorTest extends CakeTestCase {
 				'Profile'
 			)
 		));
+		
+		$arrayExpectedTmp = $arrayExpected;
+		$arrayExpectedTmp['User']['role_id'] = 1;
 		$this->assertTrue(isset($arrayResult['Profile']), 'belongsTo association via Containable: %s');
-		$this->assertEquals($arrayExpected, $arrayResult, 'belongsTo association via Containable: %s');
+		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'belongsTo association via Containable: %s');
 
 		// Same association, but this time with Linkable
 		$arrayResult = $this->User->find('first', array(
@@ -73,8 +76,10 @@ class LinkableBehaviorTest extends CakeTestCase {
 			)
 		));
 
+		$arrayExpectedTmp = $arrayExpected;
+		$arrayExpectedTmp['User']['role_id'] = 1;
 		$this->assertTrue(isset($arrayResult['Profile']), 'belongsTo association via Linkable (automatic fields): %s');
-		$this->assertEquals($arrayExpected, $arrayResult, 'belongsTo association via Linkable (automatic fields): %s');
+		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'belongsTo association via Linkable (automatic fields): %s');
 
 		// On-the-fly association via Linkable
 		$arrayExpected = array(
@@ -96,8 +101,10 @@ class LinkableBehaviorTest extends CakeTestCase {
 			)
 		));
 
+		$arrayExpectedTmp = $arrayExpected;
+		$arrayExpectedTmp['User']['role_id'] = 1;
 		$this->assertTrue(isset($arrayResult['Generic']), 'On-the-fly belongsTo association via Linkable: %s');
-		$this->assertEquals($arrayExpected, $arrayResult, 'On-the-fly belongsTo association via Linkable: %s');
+		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'On-the-fly belongsTo association via Linkable: %s');
 
 		// On-the-fly association via Linkable, with order on the associations' row and using array conditions instead of plain string
 		$arrayExpected = array(
@@ -120,7 +127,9 @@ class LinkableBehaviorTest extends CakeTestCase {
 			'order' => 'Generic.id DESC'
 		));
 
-		$this->assertEquals($arrayExpected, $arrayResult, 'On-the-fly belongsTo association via Linkable, with order: %s');
+		$arrayExpectedTmp = $arrayExpected;
+		$arrayExpectedTmp['User']['role_id'] = 3;
+		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'On-the-fly belongsTo association via Linkable, with order: %s');
 	}
 
 	public function testHasMany() {
@@ -147,8 +156,11 @@ class LinkableBehaviorTest extends CakeTestCase {
 			),
 			'order' => 'User.id ASC'
 		));
+		
+		$arrayExpectedTmp = $arrayExpected;
+		$arrayExpectedTmp['User']['role_id'] = 1;
 		$this->assertTrue(isset($arrayResult['Comment']), 'hasMany association via Containable: %s');
-		$this->assertEquals($arrayExpected, $arrayResult, 'hasMany association via Containable: %s');
+		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'hasMany association via Containable: %s');
 
 		// Same association, but this time with Linkable
 		$arrayExpected = array(
@@ -225,8 +237,10 @@ class LinkableBehaviorTest extends CakeTestCase {
 				)
 			)
 		));
-
-		$this->assertEquals($arrayExpected, $arrayResult, 'Complex find: %s');
+		
+		$arrayExpectedTmp = $arrayExpected;
+		$arrayExpectedTmp['User']['role_id'] = 1;
+		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'Complex find: %s');
 
 		// Linkable and Containable combined
 		$arrayExpected = array(
@@ -247,7 +261,9 @@ class LinkableBehaviorTest extends CakeTestCase {
 			)
 		));
 
-		$this->assertEquals($arrayExpected, $arrayResult, 'Linkable and Containable combined: %s');
+		$arrayExpectedTmp = $arrayExpected;
+		$arrayExpectedTmp['User']['role_id'] = 1;
+		$this->assertEquals($arrayExpectedTmp, $arrayResult, 'Linkable and Containable combined: %s');
 	}
 
 	public function _testPagination() {
@@ -457,7 +473,7 @@ class LinkableBehaviorTest extends CakeTestCase {
 }
 
 
-class TestModel extends CakeTestModel {
+class LinkableTestModel extends CakeTestModel {
 
 	public $recursive = 0;
 
@@ -467,7 +483,7 @@ class TestModel extends CakeTestModel {
 	);
 }
 
-class User extends TestModel {
+class User extends LinkableTestModel {
 
 	public $hasOne = array(
 		'Profile'
@@ -479,14 +495,14 @@ class User extends TestModel {
 	);
 }
 
-class Profile extends TestModel {
+class Profile extends LinkableTestModel {
 
 	public $belongsTo = array(
 		'User'
 	);
 }
 
-class BlogPost extends TestModel {
+class BlogPost extends LinkableTestModel {
 
 	public $belongsTo = array(
 		'User'
@@ -497,10 +513,10 @@ class BlogPost extends TestModel {
 	);
 }
 
-class BlogPostTag extends TestModel {
+class BlogPostTag extends LinkableTestModel {
 }
 
-class Tag extends TestModel {
+class Tag extends LinkableTestModel {
 
 	public $hasAndBelongsToMany = array(
 		'BlogPost'
@@ -514,7 +530,7 @@ class Tag extends TestModel {
 	);
 }
 
-class LegacyProduct extends TestModel {
+class LegacyProduct extends LinkableTestModel {
 
 	public $primaryKey = 'product_id';
 
@@ -530,7 +546,7 @@ class LegacyProduct extends TestModel {
 	);
 }
 
-class LegacyCompany extends TestModel {
+class LegacyCompany extends LinkableTestModel {
 
 	public $primaryKey = 'company_id';
 
@@ -542,14 +558,14 @@ class LegacyCompany extends TestModel {
 	);
 }
 
-class Shipment extends TestModel {
+class Shipment extends LinkableTestModel {
 
 	public $belongsTo = array(
 		'OrderItem'
 	);
 }
 
-class OrderItem extends TestModel {
+class OrderItem extends LinkableTestModel {
 
 	public $hasMany = array(
 		'Shipment'

+ 2 - 2
Test/Case/Model/Behavior/MasterPasswordBehaviorTest.php

@@ -12,7 +12,7 @@ class MasterPasswordBehaviorTest extends MyCakeTestCase {
 
 	public function setUp() {
 		$this->MasterPasswordBehavior = new MasterPasswordBehavior();
-		$this->Model = ClassRegistry::init('InputTestModel');
+		$this->Model = ClassRegistry::init('MasterPasswordTestModel');
 	}
 
 	public function testObject() {
@@ -163,7 +163,7 @@ class MasterPasswordBehaviorTest extends MyCakeTestCase {
 }
 
 
-class InputTestModel extends CakeTestModel {
+class MasterPasswordTestModel extends CakeTestModel {
 	public $useTable = false;
 
 }

文件差异内容过多而无法显示
+ 18151 - 9
Test/Case/Model/Behavior/SluggedBehaviorTest.php


+ 5 - 7
Test/Case/Model/Behavior/TypographicBehaviorTest.php

@@ -1,7 +1,7 @@
 <?php
 
 App::import('Behavior', 'Tools.Typographic');
-App::uses('App', 'Core');
+App::uses('AppModel', 'Model');
 App::uses('MyCakeTestCase', 'Tools.Lib');
 
 
@@ -9,7 +9,7 @@ class TypographicBehaviorTest extends MyCakeTestCase {
 
 	public function startTest() {
 		//$this->Comment = ClassRegistry::init('Comment');
-		$this->Comment = new TestModel();
+		$this->Comment = new TypographicTestModel();
 		$this->Comment->Behaviors->attach('Tools.Typographic', array('fields'=>array('body'), 'before'=>'validate'));
 	}
 
@@ -38,7 +38,7 @@ class TypographicBehaviorTest extends MyCakeTestCase {
 		$this->assertTrue($res);
 
 		$res = $this->Comment->data;
-		$this->assertSame($data['body'], $res['TestModel']['body']);
+		$this->assertSame($data['body'], $res['TypographicTestModel']['body']);
 
 		$strings = array(
 			'some string with ‹single angle quotes›' => 'some string with "single angle quotes"',
@@ -58,7 +58,7 @@ class TypographicBehaviorTest extends MyCakeTestCase {
 			//debug($expected);
 			//debug($res['TestModel']['body']);
 			//die();
-			$this->assertSame($expected, $res['TestModel']['body']);
+			$this->assertSame($expected, $res['TypographicTestModel']['body']);
 		}
 
 	}
@@ -68,10 +68,8 @@ class TypographicBehaviorTest extends MyCakeTestCase {
 
 /** other files **/
 
-class TestModel extends AppModel {
+class TypographicTestModel extends AppModel {
 
-
-	public $alias = 'TestModel';
 	public $useTable = false;
 	public $displayField = 'name';
 

+ 6 - 5
Test/Fixture/UserFixture.php

@@ -5,13 +5,14 @@ class UserFixture extends CakeTestFixture {
 
 	public $fields = array(
 		'id'			=> array('type' => 'integer', 'key' => 'primary'),
-		'username'	=> array('type' => 'string', 'length' => 255, 'null' => false)
+		'username'	=> array('type' => 'string', 'length' => 255, 'null' => false),
+		'role_id' => array('type' => 'integer')
 	);
 
 	public $records = array(
-		array('id' => 1, 'username' => 'CakePHP'),
-		array('id' => 2, 'username' => 'Zend'),
-		array('id' => 3, 'username' => 'Symfony'),
-		array('id' => 4, 'username' => 'CodeIgniter')
+		array('id' => 1, 'username' => 'CakePHP', 'role_id' => 1),
+		array('id' => 2, 'username' => 'Zend', 'role_id' => 2),
+		array('id' => 3, 'username' => 'Symfony', 'role_id' => 2),
+		array('id' => 4, 'username' => 'CodeIgniter', 'role_id' => 3)
 	);
 }

+ 1 - 0
View/Helper/BootstrapHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 
 /**
  * Generic html snippets to display some specific widgets like accordion

+ 1 - 0
View/Helper/CaptchaHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 
 if (!defined('BR')) {
 	define('BR', '<br />');

+ 1 - 0
View/Helper/CommonHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 
 /**
  * All site-wide neccessary stuff for the view layer

+ 1 - 0
View/Helper/FlattrHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 /*
 uid The Flattr User ID as found on the Flattr dashboard (in the example I used mine).
 tle The title for the link to be submitted.

+ 1 - 0
View/Helper/FormatHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('TextHelper', 'View/Helper');
 
 App::import('Helper', 'Text');
 

+ 1 - 0
View/Helper/GravatarHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 
 /**
  * CakePHP Gravatar Helper

+ 1 - 0
View/Helper/HcardHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 
 /**
  * helper for hcard, vcard and other microformats!

+ 1 - 0
View/Helper/IcalHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 
 App::uses('Helper', 'View');
 

+ 1 - 0
View/Helper/LoremHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 class LoremHelper extends AppHelper {
 	public $helpers = array('Html');
 	public $words = array();

+ 1 - 0
View/Helper/PhpThumbHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 
 /**
  * @see http://code621.com/content/1/phpthumb-helper-for-cakephp

+ 1 - 0
View/Helper/QrCodeHelper.php

@@ -1,4 +1,5 @@
 <?php
+App::uses('AppHelper', 'View/Helper');
 /**
  * Example Url:
  * http://chart.apis.google.com/chart?cht=qr&chs=400x400&chl=SomeText

+ 2 - 1
View/Helper/TreeHelper.php

@@ -1,5 +1,6 @@
 <?php
-	/* SVN FILE: $Id: tree.php 205 2008-08-13 14:13:32Z ad7six $ */
+App::uses('AppHelper', 'View/Helper');
+
 /**
  * Tree Helper.
  *