Fixing ComponentCollecction components loading, as with Behaviors and Helpers, thee MissingFileException can not be thrown

This commit is contained in:
José Lorenzo Rodríguez 2011-01-28 10:49:53 -04:30
parent 06fb51f19d
commit 4f01fc79c1
2 changed files with 4 additions and 4 deletions

View file

@ -79,7 +79,7 @@ class ComponentCollection extends ObjectCollection {
$alias = $component;
$component = $settings['className'];
}
list($plugin, $name) = pluginSplit($component);
list($plugin, $name) = pluginSplit($component, true);
if (!isset($alias)) {
$alias = $name;
}
@ -87,7 +87,7 @@ class ComponentCollection extends ObjectCollection {
return $this->_loaded[$alias];
}
$componentClass = $name . 'Component';
App::uses($componentClass, 'Controller/Component');
App::uses($componentClass, $plugin . 'Controller/Component');
if (!class_exists($componentClass)) {
throw new MissingComponentClassException(array(
'file' => Inflector::underscore($componentClass) . '.php',

View file

@ -84,7 +84,7 @@ class ComponentCollectionTest extends CakeTestCase {
$result = $this->Components->load('Cookie');
$this->assertInstanceOf('CookieAliasComponent', $result);
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)));
$result = $this->Components->load('SomeOther', array('className' => 'TestPlugin.OtherComponent'));
$this->assertInstanceOf('OtherComponentComponent', $result);
$this->assertInstanceOf('OtherComponentComponent', $this->Components->SomeOther);
@ -109,7 +109,7 @@ class ComponentCollectionTest extends CakeTestCase {
/**
* test missingcomponent exception
*
* @expectedException MissingComponentFileException
* @expectedException MissingComponentClassException
* @return void
*/
function testLoadMissingComponentFile() {