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/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php
2017-02-20 14:56:45 +01:00

62 lines
1.6 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Compiler\ResolveClassPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
class ResolveClassPassTest extends TestCase
{
/**
* @dataProvider provideValidClassId
*/
public function testResolveClassFromId($serviceId)
{
$pass = new ResolveClassPass();
$container = new ContainerBuilder();
$def = $container->register($serviceId);
$pass->process($container);
$this->assertSame($serviceId, $def->getClass());
}
public function provideValidClassId()
{
yield array('Acme\UnknownClass');
yield array(CaseSensitiveClass::class);
}
/**
* @dataProvider provideInvalidClassId
*/
public function testWontResolveClassFromId($serviceId)
{
$pass = new ResolveClassPass();
$container = new ContainerBuilder();
$def = $container->register($serviceId);
$pass->process($container);
$this->assertNull($def->getClass());
}
public function provideInvalidClassId()
{
yield array(\stdClass::class);
yield array('bar');
yield array('\DateTime');
}
}