minor #10558 [DependencyInjection] added missing unit test (fabpot)

This PR was merged into the 2.3 branch.

Discussion
----------

[DependencyInjection] added missing unit test

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Added a unit test to ensure that #10536 won't break BC.

Commits
-------

47d1592 added missing unit test
This commit is contained in:
Fabien Potencier 2014-03-27 15:52:08 +01:00
commit ea4b8bf993
1 changed files with 20 additions and 1 deletions

View File

@ -21,6 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@ -151,6 +152,16 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertNull($builder->get('foo', ContainerInterface::NULL_ON_INVALID_REFERENCE));
}
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::get
*/
public function testGetReturnsNullOnInactiveScopeWhenServiceIsCreatedByAMethod()
{
$builder = new ProjectContainer();
$this->assertNull($builder->get('foobaz', ContainerInterface::NULL_ON_INVALID_REFERENCE));
}
/**
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds
*/
@ -805,8 +816,16 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
}
}
$this->assertEquals(true, $classInList);
$this->assertTrue($classInList);
}
}
class FooClass {}
class ProjectContainer extends ContainerBuilder
{
public function getFoobazService()
{
throw new InactiveScopeException('foo', 'request');
}
}