Index: tests/Zend/Loader/Autoloader/ResourceTest.php =================================================================== --- tests/Zend/Loader/Autoloader/ResourceTest.php (revision 23564) +++ tests/Zend/Loader/Autoloader/ResourceTest.php (working copy) @@ -419,6 +419,49 @@ $path = $this->loader->autoload('Something_Totally_Wrong'); $this->assertFalse($path); } + + /** + * @group ZF-10836 + */ + public function testAutoloaderResourceConstructorDataArgumentNamespaceKeyMustPreceedResourceTypesKey() + { + // Set up autoloader where namespace key is in the "wrong" place + $data = array( + 'basePath' => 'path/to/some/directory', + 'resourceTypes' => array( + 'acl' => array( + 'path' => 'acls/', + 'namespace' => 'Acl', + ), + 'form' => array( + 'path' => 'forms/', + 'namespace' => 'Form', + ) + ), + 'namespace' => 'My' + ); + $zlar1 = new Zend_Loader_Autoloader_Resource($data); + + // Set up autoloader where namespace is in the "right" place + $data = array( + 'basePath' => 'path/to/some/directory', + 'namespace' => 'My', + 'resourceTypes' => array( + 'acl' => array( + 'path' => 'acls/', + 'namespace' => 'Acl', + ), + 'form' => array( + 'path' => 'forms/', + 'namespace' => 'Form', + ) + ) + ); + $zlar2 = new Zend_Loader_Autoloader_Resource($data); + + // Check that the results are the same + $this->assertEquals($zlar1, $zlar2); + } } if (PHPUnit_MAIN_METHOD == 'Zend_Loader_Autoloader_ResourceTest::main') { Index: library/Zend/Loader/Autoloader/Resource.php =================================================================== --- library/Zend/Loader/Autoloader/Resource.php (revision 23564) +++ library/Zend/Loader/Autoloader/Resource.php (working copy) @@ -206,6 +206,17 @@ */ public function setOptions(array $options) { + // If namespace key exists, shift it to be beginning of the options array + // so that it is processed first + // @see ZF-10836 + $namespaceIndex = array_search('namespace', array_keys($options)); + if ( $namespaceIndex !== false ) + { + $namespace = $options['namespace']; + unset($options['namespace']); + $options = array('namespace'=>$namespace) + $options; + } + $methods = get_class_methods($this); foreach ($options as $key => $value) { $method = 'set' . ucfirst($key);