From e81ff384c7b21e13f2df4150909c13202b734cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 01:48:15 -0430 Subject: [PATCH] Fixing BehaviorCollection test regarding how classes are loaded. with the introduction of App::uses() it is not possible to determine if a file is missing or just the class in the file, so removing the throwing of MissingBehaviorFileException seems the only choice --- lib/Cake/Model/BehaviorCollection.php | 6 +++--- .../tests/cases/libs/model/behavior_collection.test.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index 7cb353224..a75b6deec 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -96,21 +96,21 @@ class BehaviorCollection extends ObjectCollection { * @param string $behavior CamelCased name of the behavior to load * @param array $config Behavior configuration parameters * @return boolean True on success, false on failure - * @throws MissingBehaviorFileException or MissingBehaviorClassException when a behavior could not be found. + * @throws MissingBehaviorClassException when a behavior could not be found. */ public function load($behavior, $config = array()) { if (is_array($config) && isset($config['className'])) { $alias = $behavior; $behavior = $config['className']; } - list($plugin, $name) = pluginSplit($behavior); + list($plugin, $name) = pluginSplit($behavior, true); if (!isset($alias)) { $alias = $name; } $class = $name . 'Behavior'; - App::uses($class, 'Model/Behavior'); + App::uses($class, $plugin . 'Model/Behavior'); if (!class_exists($class)) { throw new MissingBehaviorClassException(array( 'file' => Inflector::underscore($behavior) . '.php', diff --git a/lib/Cake/tests/cases/libs/model/behavior_collection.test.php b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php index 1f38ae97c..6724c2784 100644 --- a/lib/Cake/tests/cases/libs/model/behavior_collection.test.php +++ b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php @@ -453,7 +453,7 @@ class BehaviorCollectionTest extends CakeTestCase { $this->assertEquals($Apple->testMethod(true), 'working'); $this->assertEquals($Apple->Behaviors->dispatchMethod($Apple, 'testMethod'), 'working'); - App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS))); + App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS))); $this->assertTrue($Apple->Behaviors->load('SomeOther', array('className' => 'TestPlugin.TestPluginPersisterOne'))); $this->assertInstanceOf('TestPluginPersisterOneBehavior', $Apple->Behaviors->SomeOther); @@ -553,7 +553,7 @@ class BehaviorCollectionTest extends CakeTestCase { /** * test that attaching a non existant Behavior triggers a cake error. * - * @expectedException MissingBehaviorFileException + * @expectedException MissingBehaviorClassException * @return void */ function testInvalidBehaviorCausingCakeError() {