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' into feature/db-story-35
Browse files Browse the repository at this point in the history
[zen-35]

Conflicts:
	library/Zend/Db/Sql/Select.php
	tests/Zend/Db/Sql/SelectTest.php
  • Loading branch information
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .travis/run-tests.sh
@@ -0,0 +1,14 @@
#!/bin/bash
travisdir=$(dirname $(readlink /proc/$$/fd/255))
testdir="$travisdir/../tests"
testedcomponents=(`cat "$travisdir/tested-components"`)
result=0

for tested in "${testedcomponents[@]}"
do
echo "$tested:"
phpunit -c $testdir/phpunit.xml $testdir/$tested
let "result = $result || $?"
done

exit $result
9 changes: 9 additions & 0 deletions .travis/skipped-components
@@ -0,0 +1,9 @@
Zend/Amf
Zend/Barcode
Zend/Date
Zend/Feed
Zend/Queue
Zend/Service
Zend/Test
Zend/Translator
Zend/Wildfire
58 changes: 58 additions & 0 deletions .travis/tested-components
@@ -0,0 +1,58 @@
Zend/Acl
Zend/Authentication
Zend/Cache
Zend/Captcha
Zend/Cloud
Zend/Code
Zend/Config
Zend/Console
Zend/Crypt
Zend/Currency
Zend/Db
Zend/Di
Zend/Docbook
Zend/Dojo
Zend/Dom
Zend/EventManager
Zend/Feed/Reader
Zend/Feed/Writer
Zend/File
Zend/Filter
Zend/Form
Zend/GData
Zend/Http
Zend/InfoCard
Zend/Json
Zend/Ldap
Zend/Loader
Zend/Locale
Zend/Log
Zend/Mail
Zend/Markup
Zend/Measure
Zend/Memory
Zend/Mime
Zend/Module
Zend/Mvc
Zend/Navigation
Zend/OAuth
Zend/OpenId
Zend/Paginator
Zend/Pdf
Zend/ProgressBar
Zend/RegistryTest.php
Zend/Rest
Zend/Search
Zend/Serializer
Zend/Server
Zend/Session
Zend/Soap
Zend/Stdlib
Zend/Tag
Zend/Text
Zend/TimeSync
Zend/Uri
Zend/Validator
Zend/VersionTest.php
Zend/View
Zend/XmlRpc
16 changes: 15 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 @@ -107,6 +108,19 @@ protected function processClass($class)
}
}

$rTarget = $rClass;
$supertypes = array();
do {
$supertypes = array_merge($supertypes, $rTarget->getInterfaceNames());
if (!($rTargetParent = $rTarget->getParentClass())) {
break;
}
$supertypes[] = $rTargetParent->getName();
$rTarget = $rTargetParent;
} while (true);

$def['supertypes'] = $supertypes;

if ($def['instantiator'] == null) {
if ($rClass->isInstantiable()) {
$def['instantiator'] = '__construct';
Expand Down Expand Up @@ -395,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
37 changes: 37 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 @@ -42,4 +43,40 @@ public function testCompilerCompilesAgainstConstructorInjectionAssets()
$definition->getMethodParameters('ZendTest\Di\TestAsset\CompilerClasses\C', 'setB')
);
}

public function testCompilerSupertypes()
{
$definition = new CompilerDefinition;
$definition->addDirectory(__DIR__ . '/../TestAsset/CompilerClasses');
$definition->compile();
$this->assertCount(0, $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\C'));
$this->assertCount(1, $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\D'));
$this->assertCount(2, $definition->getClassSupertypes('ZendTest\Di\TestAsset\CompilerClasses\E'));
$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 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'));
}
}
8 changes: 8 additions & 0 deletions test/TestAsset/CompilerClasses/E.php
@@ -0,0 +1,8 @@
<?php

namespace ZendTest\Di\TestAsset\CompilerClasses;

class E extends D
{

}

0 comments on commit 9d9d2be

Please sign in to comment.