[DependencyInjection] added a test for the previous merge (refs #7261)
This commit is contained in:
parent
71cba81b89
commit
dcb1441d23
@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
@ -116,6 +117,26 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue($builder->get('bar') === $builder->get('bar'), '->get() always returns the same instance if the service is shared');
|
$this->assertTrue($builder->get('bar') === $builder->get('bar'), '->get() always returns the same instance if the service is shared');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \Symfony\Component\DependencyInjection\ContainerBuilder::get
|
||||||
|
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||||
|
* @expectedExceptionMessage You have requested a synthetic service ("foo"). The DIC does not know how to construct this service.
|
||||||
|
*/
|
||||||
|
public function testGetXXX()
|
||||||
|
{
|
||||||
|
$builder = new ContainerBuilder();
|
||||||
|
$builder->register('foo', 'stdClass')->setSynthetic(true);
|
||||||
|
|
||||||
|
// we expect a RuntimeException here as foo is synthetic
|
||||||
|
try {
|
||||||
|
$builder->get('foo');
|
||||||
|
} catch (RuntimeException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// we must also have the same RuntimeException here
|
||||||
|
$builder->get('foo');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds
|
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::getServiceIds
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user