Skip to content

Commit b0c42fb

Browse files
hasonnicolas-grekas
authored andcommitted
[DependencyInjection] Tests for AutowirePass with missing parent class
1 parent b90deb2 commit b0c42fb

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Tests/Compiler/AutowirePassTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,21 @@ public function testOptionalScalarArgsNotPassedIfLast()
397397
$definition->getArguments()
398398
);
399399
}
400+
401+
public function testIgnoreServiceWithClassNotExisting()
402+
{
403+
$container = new ContainerBuilder();
404+
405+
$container->register('class_not_exist', __NAMESPACE__.'\OptionalServiceClass');
406+
407+
$barDefinition = $container->register('bar', __NAMESPACE__.'\Bar');
408+
$barDefinition->setAutowired(true);
409+
410+
$pass = new AutowirePass();
411+
$pass->process($container);
412+
413+
$this->assertTrue($container->hasDefinition('bar'));
414+
}
400415
}
401416

402417
class Foo
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
13+
14+
use Symfony\Bug\NotExistClass;
15+
16+
class OptionalServiceClass extends NotExistClass
17+
{
18+
}

0 commit comments

Comments
 (0)