Permalink
Browse files

Merge branch 'hotfix/di-definitionInterface-api-consistency' of https…

  • Loading branch information...
weierophinney committed Aug 30, 2012
2 parents bf30302 + 26f013f commit bfce4519d4e03727fecc25da7f1063bee9674564
@@ -89,11 +89,11 @@ public function getInstantiator($class)
public function hasMethods($class)
{
if (!isset($this->dataArray[$class])) {
return array();
return false;
}
if (!isset($this->dataArray[$class]['methods'])) {
return array();
return false;
}
return (count($this->dataArray[$class]['methods']) > 0);
@@ -152,7 +152,7 @@ public function getInstantiator($class)
*/
public function hasMethods($class)
{
return ($this->methods);
return (count($this->methods) > 0);
}
/**
@@ -15,7 +15,6 @@
class ArrayDefinitionTest extends TestCase
{
/**
* @var ArrayDefinition
*/
@@ -36,6 +35,16 @@ public function testArrayDefinitionHasClasses()
$this->assertFalse($this->definition->hasClass('My\Foo'));
}
public function testArrayDefinitionHasMethods()
{
$this->assertTrue($this->definition->hasMethods('My\Mapper'));
$this->assertFalse($this->definition->hasMethods('My\EntityA'));
$this->assertTrue($this->definition->hasMethods('My\Mapper'));
$this->assertFalse($this->definition->hasMethods('My\RepositoryA'));
$this->assertFalse($this->definition->hasMethods('My\RepositoryB'));
$this->assertFalse($this->definition->hasMethods('My\Foo'));
}
public function testArrayDefinitionCanGetClassses()
{
$list = array(
@@ -60,7 +69,6 @@ public function testArrayDefinitionCanGetClassSupertypes()
$this->assertContains('My\RepositoryA', $this->definition->getClassSupertypes('My\RepositoryB'));
}
public function testArrayDefinitionCanGetInstantiator()
{
$this->assertEquals('__construct', $this->definition->getInstantiator('My\RepositoryA'));
@@ -86,7 +94,4 @@ public function testArrayDefinitionGetInjectionMethodParameters()
{
$this->markTestIncomplete();
}
}
@@ -17,7 +17,6 @@
class BuilderDefinitionTest extends TestCase
{
public function testBuilderImplementsDefinition()
{
$builder = new BuilderDefinition();
@@ -51,6 +50,28 @@ public function testBuilderCanBuildClassWithMethods()
);
}
public function testBuilderDefinitionHasMethodsThrowsRuntimeException()
{
$definition = new BuilderDefinition();
$this->setExpectedException('Zend\Di\Exception\RuntimeException');
$definition->hasMethods('Foo');
}
public function testBuilderDefinitionHasMethods()
{
$class = new Builder\PhpClass();
$class->setName('Foo');
$definition = new BuilderDefinition();
$definition->addClass($class);
$this->assertFalse($definition->hasMethods('Foo'));
$class->createInjectionMethod('injectBar');
$this->assertTrue($definition->hasMethods('Foo'));
}
public function testBuilderCanBuildFromArray()
{
$ini = ConfigFactory::fromFile(__DIR__ . '/../_files/sample.ini');
@@ -0,0 +1,30 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Di
*/
namespace ZendTest\Di\Definition;
use Zend\Di\Definition\ClassDefinition;
use PHPUnit_Framework_TestCase as TestCase;
class ClassDefinitionTest extends TestCase
{
public function testClassImplementsDefinition()
{
$definition = new ClassDefinition('Foo');
$this->assertInstanceOf('Zend\Di\Definition\DefinitionInterface', $definition);
}
public function testClassDefinitionHasMethods()
{
$definition = new ClassDefinition('Foo');
$this->assertFalse($definition->hasMethods('Foo'));
$definition->addMethod('doBar');
$this->assertTrue($definition->hasMethods('Foo'));
}
}

0 comments on commit bfce451

Please sign in to comment.