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

Commit

Permalink
Merge branch 'hotfix/session-container-exchangeArray' of github.com:m…
Browse files Browse the repository at this point in the history
…arc-mabe/zf2 into feature/cache-session-storage
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/ClassMapAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ public function getAutoloadMap()
}

/**
* Defined by Autoloadable
*
* @param string $class
* @return void
* {@inheritDoc}
*/
public function autoload($class)
{
if (isset($this->map[$class])) {
require_once $this->map[$class];

return $class;
}

return false;
}

/**
Expand Down
8 changes: 5 additions & 3 deletions test/ClassMapAutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,16 @@ public function testAutoloadLoadsClasses()
{
$map = array('ZendTest\UnusualNamespace\ClassMappedClass' => __DIR__ . '/TestAsset/ClassMappedClass.php');
$this->loader->registerAutoloadMap($map);
$this->loader->autoload('ZendTest\UnusualNamespace\ClassMappedClass');
$loaded = $this->loader->autoload('ZendTest\UnusualNamespace\ClassMappedClass');
$this->assertSame('ZendTest\UnusualNamespace\ClassMappedClass', $loaded);
$this->assertTrue(class_exists('ZendTest\UnusualNamespace\ClassMappedClass', false));
}

public function testIgnoresClassesNotInItsMap()
{
$map = array('ZendTest\UnusualNamespace\ClassMappedClass' => __DIR__ . '/TestAsset/ClassMappedClass.php');
$this->loader->registerAutoloadMap($map);
$this->loader->autoload('ZendTest\UnusualNamespace\UnMappedClass');
$this->assertFalse($this->loader->autoload('ZendTest\UnusualNamespace\UnMappedClass'));
$this->assertFalse(class_exists('ZendTest\UnusualNamespace\UnMappedClass', false));
}

Expand All @@ -172,7 +173,8 @@ public function testCanLoadClassMapFromPhar()
{
$map = 'phar://' . __DIR__ . '/_files/classmap.phar/test/.//../autoload_classmap.php';
$this->loader->registerAutoloadMap($map);
$this->loader->autoload('some\loadedclass');
$loaded = $this->loader->autoload('some\loadedclass');
$this->assertSame('some\loadedclass', $loaded);
$this->assertTrue(class_exists('some\loadedclass', false));

// will not register duplicate, even with a different relative path
Expand Down

0 comments on commit 2d10645

Please sign in to comment.