2011-02-02 17:22:27 +00:00
|
|
|
<?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.
|
|
|
|
*/
|
|
|
|
|
2011-02-02 17:22:27 +00:00
|
|
|
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
|
|
|
}
|