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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Definition/CompilerDefinition.php
Expand Up @@ -5,6 +5,7 @@
use Zend\Code\Scanner\DerivedClassScanner,
Zend\Code\Scanner\AggregateDirectoryScanner,
Zend\Code\Scanner\DirectoryScanner,
Zend\Code\Scanner\FileScanner,

Zend\Di\Definition\Annotation,
Zend\Code\Annotation\AnnotationManager,
Expand Down Expand Up @@ -408,7 +409,7 @@ public function hasClass($class)
*/
public function getClassSupertypes($class)
{
if (!array_key_exists($class, $this->classes[$class])) {
if (!array_key_exists($class, $this->classes)) {
$this->processClass($class);
}
return $this->classes[$class]['supertypes'];
Expand Down
2 changes: 1 addition & 1 deletion src/Definition/RuntimeDefinition.php
Expand Up @@ -105,7 +105,7 @@ public function hasClass($class)
*/
public function getClassSupertypes($class)
{
if (!array_key_exists($class, $this->classes[$class])) {
if (!array_key_exists($class, $this->classes)) {
$this->processClass($class);
}
return $this->classes[$class]['supertypes'];
Expand Down
24 changes: 24 additions & 0 deletions test/Definition/CompilerDefinitionTest.php
Expand Up @@ -4,6 +4,7 @@

use Zend\Di\Definition\CompilerDefinition,
Zend\Code\Scanner\DirectoryScanner,
Zend\Code\Scanner\FileScanner,
PHPUnit_Framework_TestCase as TestCase;

class CompilerDefinitionTest extends TestCase
Expand Down Expand Up @@ -55,4 +56,27 @@ public function testCompilerSupertypes()
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\C', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\D', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
}

public function testCompilerDirectoryScannerAndFileScanner()
{
$definition = new CompilerDefinition;
$definition->addDirectoryScanner(new DirectoryScanner(__DIR__ . '/../TestAsset/CompilerClasses'));
$definition->addCodeScannerFile(new FileScanner(__DIR__ . '/../TestAsset/CompilerClasses/A.php'));
$definition->compile();
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\C', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\D'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\C', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\D', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
}

public function testCompilerFileScanner()
{
$definition = new CompilerDefinition;
$definition->addCodeScannerFile(new FileScanner(__DIR__ . '/../TestAsset/CompilerClasses/C.php'));
$definition->addCodeScannerFile(new FileScanner(__DIR__ . '/../TestAsset/CompilerClasses/D.php'));
$definition->addCodeScannerFile(new FileScanner(__DIR__ . '/../TestAsset/CompilerClasses/E.php'));
$definition->compile();
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\C', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\D'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\C', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
$this->assertContains('ZendTest\Di\TestAsset\CompilerClasses\D', $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
}
}

0 comments on commit be06520

Please sign in to comment.