[DependencyInjection] Added a test for a frozen constructor of a container with no parameters
This commit is contained in:
parent
3d32a0bcc2
commit
2a124bc89c
@ -37,6 +37,20 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
|
|||||||
new PhpDumper($container);
|
new PhpDumper($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDumpFrozenContainerWithNoParameter()
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->register('foo', 'stdClass');
|
||||||
|
|
||||||
|
$container->compile();
|
||||||
|
|
||||||
|
$dumper = new PhpDumper($container);
|
||||||
|
|
||||||
|
$dumpedString = $dumper->dump();
|
||||||
|
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services11.php', $dumpedString, '->dump() does not add getDefaultParameters() method call if container have no parameters.');
|
||||||
|
$this->assertNotRegexp("/function getDefaultParameters\(/", $dumpedString, '->dump() does not add getDefaultParameters() method definition.');
|
||||||
|
}
|
||||||
|
|
||||||
public function testDumpOptimizationString()
|
public function testDumpOptimizationString()
|
||||||
{
|
{
|
||||||
$definition = new Definition();
|
$definition = new Definition();
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\InactiveScopeException;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\DependencyInjection\Parameter;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProjectServiceContainer
|
||||||
|
*
|
||||||
|
* This class has been auto-generated
|
||||||
|
* by the Symfony Dependency Injection Component.
|
||||||
|
*/
|
||||||
|
class ProjectServiceContainer extends Container
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->services =
|
||||||
|
$this->scopedServices =
|
||||||
|
$this->scopeStacks = array();
|
||||||
|
|
||||||
|
$this->set('service_container', $this);
|
||||||
|
|
||||||
|
$this->scopes = array();
|
||||||
|
$this->scopeChildren = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the 'foo' service.
|
||||||
|
*
|
||||||
|
* This service is shared.
|
||||||
|
* This method always returns the same instance of the service.
|
||||||
|
*
|
||||||
|
* @return stdClass A stdClass instance.
|
||||||
|
*/
|
||||||
|
protected function getFooService()
|
||||||
|
{
|
||||||
|
return $this->services['foo'] = new \stdClass();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user