Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://git.zendframework.com/zf
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkael committed Jul 22, 2010
5 parents 204968d + 9201751 + 4bc3149 + f6850f1 + 995dd45 commit 8bf7d74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/PluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public function removePrefixPath($prefix, $path = null)

if ($path != null) {
$pos = array_search($path, $registry[$prefix]);
if (in_array($pos, array(null, false))) {
if (false === $pos) {
throw new PluginLoaderException('Prefix ' . $prefix . ' / Path ' . $path . ' was not found in the PluginLoader.');
}
unset($registry[$prefix][$pos]);
Expand Down
18 changes: 17 additions & 1 deletion test/PluginLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public function testClassFilesGrabCorrectPathForLoadedClasses()
$paths = $loader->getPaths();
$this->fail(sprintf("Failed loading helper; paths: %s", var_export($paths, 1)));
}

$classPath = $loader->getClassPath('DeclareVars');
$this->assertContains($expected, $classPath);
}
Expand All @@ -462,4 +462,20 @@ public function testPrefixesEndingInBackslashDenoteNamespacedClasses()
$this->assertEquals('Zfns\\Foo', $className);
$this->assertEquals('Zfns\\Foo', $loader->getClassName('Foo'));
}

/**
* @group ZF-9721
*/
public function testRemovePrefixPathThrowsExceptionIfPathNotRegisteredInPrefix()
{
try {
$loader = new Zend_Loader_PluginLoader(array('My_Namespace_' => 'My/Namespace/'));
$loader->removePrefixPath('My_Namespace_', 'ZF9721');
$this->fail();
} catch (Exception $e) {
$this->assertType('Zend_Loader_PluginLoader_Exception', $e);
$this->assertContains('Prefix My_Namespace_ / Path ZF9721', $e->getMessage());
}
$this->assertEquals(1, count($loader->getPaths('My_Namespace_')));
}
}

0 comments on commit 8bf7d74

Please sign in to comment.