This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/DependencyInjection/Compiler/CheckDefinitionValidityPassTest.php

70 lines
2.0 KiB
PHP
Raw Normal View History

<?php
2011-05-31 09:57:06 +01:00
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Symfony\Tests\Component\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CheckDefinitionValidityPass;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class CheckDefinitionValidityPassTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \RuntimeException
*/
public function testProcessDetectsSyntheticNonPublicDefinitions()
{
$container = new ContainerBuilder();
$container->register('a')->setSynthetic(true)->setPublic(false);
$this->process($container);
}
/**
* @expectedException \RuntimeException
*/
public function testProcessDetectsSyntheticPrototypeDefinitions()
{
$container = new ContainerBuilder();
$container->register('a')->setSynthetic(true)->setScope(ContainerInterface::SCOPE_PROTOTYPE);
$this->process($container);
}
/**
* @expectedException \RuntimeException
*/
public function testProcessDetectsNonSyntheticNonAbstractDefinitionWithoutClass()
{
$container = new ContainerBuilder();
$container->register('a')->setSynthetic(false)->setAbstract(false);
$this->process($container);
}
public function testProcess()
{
$container = new ContainerBuilder();
$container->register('a', 'class');
$container->register('b', 'class')->setSynthetic(true)->setPublic(true);
$container->register('c', 'class')->setAbstract(true);
$container->register('d', 'class')->setSynthetic(true);
$this->process($container);
}
protected function process(ContainerBuilder $container)
{
$pass = new CheckDefinitionValidityPass();
$pass->process($container);
}
2011-06-08 18:56:59 +01:00
}