Skip to content

Commit

Permalink
Add more tests on ObjectDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jan 4, 2017
1 parent c2cee94 commit f24d749
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/UnitTest/Definition/ObjectDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use DI\Definition\CacheableDefinition;
use DI\Definition\ObjectDefinition;
use DI\Definition\ObjectDefinition\MethodInjection;
use DI\Definition\ObjectDefinition\PropertyInjection;
use DI\Scope;
use DI\Test\UnitTest\Definition\Fixture\NonInstantiableClass;

Expand Down Expand Up @@ -58,6 +60,31 @@ public function test_is_instantiable()
self::assertTrue($definition->classExists());
}

public function test_property_injections()
{
$definition = new ObjectDefinition('foo');
$definition->addPropertyInjection(new PropertyInjection('property1', 'Property1'));
$definition->addPropertyInjection(new PropertyInjection('property2', 'Property2'));
$this->assertEquals([
'property1' => new PropertyInjection('property1', 'Property1'),
'property2' => new PropertyInjection('property2', 'Property2'),
], $definition->getPropertyInjections());
}

public function test_method_injections()
{
$definition = new ObjectDefinition('foo');
$definition->setConstructorInjection(MethodInjection::constructor());
$definition->addMethodInjection(new MethodInjection('method1', ['foo']));
$definition->addMethodInjection(new MethodInjection('method2'));

$this->assertNotNull($definition->getConstructorInjection());
$this->assertEquals([
new MethodInjection('method1', ['foo']),
new MethodInjection('method2'),
], $definition->getMethodInjections());
}

/**
* @test
*/
Expand Down

0 comments on commit f24d749

Please sign in to comment.