|
12 | 12 | namespace Symfony\Component\HttpKernel\Tests; |
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\Config\Loader\LoaderInterface; |
15 | 16 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
16 | 17 | use Symfony\Component\HttpKernel\Bundle\BundleInterface; |
17 | 18 | use Symfony\Component\HttpKernel\Config\EnvParametersResource; |
@@ -761,6 +762,15 @@ public function testSymfonyEnvironmentVariables() |
761 | 762 | unset($_SERVER['SYMFONY__FOO__BAR']); |
762 | 763 | } |
763 | 764 |
|
| 765 | + public function testProjectDirExtension() |
| 766 | + { |
| 767 | + $kernel = new CustomProjectDirKernel('test', true); |
| 768 | + $kernel->boot(); |
| 769 | + |
| 770 | + $this->assertSame('foo', $kernel->getProjectDir()); |
| 771 | + $this->assertSame('foo', $kernel->getContainer()->getParameter('kernel.project_dir')); |
| 772 | + } |
| 773 | + |
764 | 774 | /** |
765 | 775 | * Returns a mock for the BundleInterface. |
766 | 776 | * |
@@ -857,3 +867,34 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = |
857 | 867 | { |
858 | 868 | } |
859 | 869 | } |
| 870 | + |
| 871 | +class CustomProjectDirKernel extends Kernel |
| 872 | +{ |
| 873 | + private $baseDir; |
| 874 | + |
| 875 | + public function __construct() |
| 876 | + { |
| 877 | + parent::__construct('test', false); |
| 878 | + |
| 879 | + $this->baseDir = 'foo'; |
| 880 | + } |
| 881 | + |
| 882 | + public function registerBundles() |
| 883 | + { |
| 884 | + return array(); |
| 885 | + } |
| 886 | + |
| 887 | + public function registerContainerConfiguration(LoaderInterface $loader) |
| 888 | + { |
| 889 | + } |
| 890 | + |
| 891 | + public function getProjectDir() |
| 892 | + { |
| 893 | + return $this->baseDir; |
| 894 | + } |
| 895 | + |
| 896 | + public function getRootDir() |
| 897 | + { |
| 898 | + return __DIR__.'/Fixtures'; |
| 899 | + } |
| 900 | +} |
0 commit comments