|
17 | 17 |
|
18 | 18 | use PHPUnit\Framework\TestCase;
|
19 | 19 | use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
|
| 20 | +use Symfony\Component\Config\FileLocator; |
20 | 21 | use Symfony\Component\Config\Resource\DirectoryResource;
|
21 | 22 | use Symfony\Component\Config\Resource\FileResource;
|
22 | 23 | use Symfony\Component\Config\Resource\ResourceInterface;
|
|
44 | 45 | use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
45 | 46 | use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator;
|
46 | 47 | use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
| 48 | +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; |
| 49 | +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; |
47 | 50 | use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
|
48 | 51 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
49 | 52 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
56 | 59 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
|
57 | 60 | use Symfony\Component\DependencyInjection\Tests\Fixtures\CustomDefinition;
|
58 | 61 | use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument;
|
| 62 | +use Symfony\Component\DependencyInjection\Tests\Fixtures\ProxyAndInheritance; |
59 | 63 | use Symfony\Component\DependencyInjection\Tests\Fixtures\ScalarFactory;
|
60 | 64 | use Symfony\Component\DependencyInjection\Tests\Fixtures\SimilarArgumentsDummy;
|
61 | 65 | use Symfony\Component\DependencyInjection\Tests\Fixtures\StringBackedEnum;
|
@@ -2125,6 +2129,35 @@ public function testLazyClosure()
|
2125 | 2129 | $this->assertSame(1 + $cloned, Foo::$counter);
|
2126 | 2130 | $this->assertSame(1, (new \ReflectionFunction($container->get('closure')))->getNumberOfParameters());
|
2127 | 2131 | }
|
| 2132 | + |
| 2133 | + public function testProxyAndInheritance() |
| 2134 | + { |
| 2135 | + $container = new ContainerBuilder(); |
| 2136 | + |
| 2137 | + $phpLoader = new PhpFileLoader($container, new FileLocator()); |
| 2138 | + $instanceof = []; |
| 2139 | + $configurator = new ContainerConfigurator($container, $phpLoader, $instanceof, __DIR__, __FILE__); |
| 2140 | + |
| 2141 | + $services = $configurator->services(); |
| 2142 | + $services |
| 2143 | + ->defaults() |
| 2144 | + ->autowire() |
| 2145 | + ->autoconfigure() |
| 2146 | + ->public() |
| 2147 | + |
| 2148 | + ->load('Symfony\Component\DependencyInjection\Tests\Fixtures\ProxyAndInheritance\\', __DIR__.'/Fixtures/ProxyAndInheritance/*') |
| 2149 | + ; |
| 2150 | + |
| 2151 | + $services->set( |
| 2152 | + ProxyAndInheritance\Application::class, |
| 2153 | + ProxyAndInheritance\RepackedApplication::class, |
| 2154 | + ); |
| 2155 | + |
| 2156 | + $container->compile(true); |
| 2157 | + |
| 2158 | + $foo = $container->get(ProxyAndInheritance\Foo::class); |
| 2159 | + $this->assertSame('my-app', $foo->getApplicationName()); |
| 2160 | + } |
2128 | 2161 | }
|
2129 | 2162 |
|
2130 | 2163 | class FooClass
|
|
0 commit comments