class RemoveUnusedDefinitionsPassTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php \Symfony\Component\DependencyInjection\Tests\Compiler\RemoveUnusedDefinitionsPassTest
Hierarchy
- class \Symfony\Component\DependencyInjection\Tests\Compiler\RemoveUnusedDefinitionsPassTest extends \Symfony\Component\DependencyInjection\Tests\Compiler\PHPUnit_Framework_TestCase
Expanded class hierarchy of RemoveUnusedDefinitionsPassTest
File
- vendor/
symfony/ dependency-injection/ Tests/ Compiler/ RemoveUnusedDefinitionsPassTest.php, line 21
Namespace
Symfony\Component\DependencyInjection\Tests\CompilerView source
class RemoveUnusedDefinitionsPassTest extends \PHPUnit_Framework_TestCase {
public function testProcess() {
$container = new ContainerBuilder();
$container
->register('foo')
->setPublic(false);
$container
->register('bar')
->setPublic(false);
$container
->register('moo')
->setArguments(array(
new Reference('bar'),
));
$this
->process($container);
$this
->assertFalse($container
->hasDefinition('foo'));
$this
->assertTrue($container
->hasDefinition('bar'));
$this
->assertTrue($container
->hasDefinition('moo'));
}
public function testProcessRemovesUnusedDefinitionsRecursively() {
$container = new ContainerBuilder();
$container
->register('foo')
->setPublic(false);
$container
->register('bar')
->setArguments(array(
new Reference('foo'),
))
->setPublic(false);
$this
->process($container);
$this
->assertFalse($container
->hasDefinition('foo'));
$this
->assertFalse($container
->hasDefinition('bar'));
}
public function testProcessWorksWithInlinedDefinitions() {
$container = new ContainerBuilder();
$container
->register('foo')
->setPublic(false);
$container
->register('bar')
->setArguments(array(
new Definition(null, array(
new Reference('foo'),
)),
));
$this
->process($container);
$this
->assertTrue($container
->hasDefinition('foo'));
$this
->assertTrue($container
->hasDefinition('bar'));
}
public function testProcessWontRemovePrivateFactory() {
$container = new ContainerBuilder();
$container
->register('foo', 'stdClass')
->setFactory(array(
'stdClass',
'getInstance',
))
->setPublic(false);
$container
->register('bar', 'stdClass')
->setFactory(array(
new Reference('foo'),
'getInstance',
))
->setPublic(false);
$container
->register('foobar')
->addArgument(new Reference('bar'));
$this
->process($container);
$this
->assertTrue($container
->hasDefinition('foo'));
$this
->assertTrue($container
->hasDefinition('bar'));
$this
->assertTrue($container
->hasDefinition('foobar'));
}
protected function process(ContainerBuilder $container) {
$repeatedPass = new RepeatedPass(array(
new AnalyzeServiceReferencesPass(),
new RemoveUnusedDefinitionsPass(),
));
$repeatedPass
->process($container);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RemoveUnusedDefinitionsPassTest:: |
protected | function | ||
RemoveUnusedDefinitionsPassTest:: |
public | function | ||
RemoveUnusedDefinitionsPassTest:: |
public | function | ||
RemoveUnusedDefinitionsPassTest:: |
public | function | ||
RemoveUnusedDefinitionsPassTest:: |
public | function |