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

This commit is contained in:
José Lorenzo Rodríguez 2011-01-28 01:48:15 -04:30
parent 0bde6d35f5
commit e81ff384c7
2 changed files with 5 additions and 5 deletions

View file

@ -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',

View file

@ -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() {