|
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;
|
| 17 | +use Symfony\Component\Filesystem\Filesystem; |
16 | 18 | use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
17 | 19 | use Symfony\Component\HttpKernel\Config\EnvParametersResource;
|
18 | 20 | use Symfony\Component\HttpKernel\Kernel;
|
@@ -761,6 +763,15 @@ public function testSymfonyEnvironmentVariables()
|
761 | 763 | unset($_SERVER['SYMFONY__FOO__BAR']);
|
762 | 764 | }
|
763 | 765 |
|
| 766 | + public function testProjectDirExtension() |
| 767 | + { |
| 768 | + $kernel = new CustomProjectDirKernel('test', true); |
| 769 | + $kernel->boot(); |
| 770 | + |
| 771 | + $this->assertSame('foo', $kernel->getProjectDir()); |
| 772 | + $this->assertSame('foo', $kernel->getContainer()->getParameter('kernel.project_dir')); |
| 773 | + } |
| 774 | + |
764 | 775 | /**
|
765 | 776 | * Returns a mock for the BundleInterface.
|
766 | 777 | *
|
@@ -857,3 +868,37 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
|
857 | 868 | {
|
858 | 869 | }
|
859 | 870 | }
|
| 871 | + |
| 872 | +class CustomProjectDirKernel extends Kernel |
| 873 | +{ |
| 874 | + private $baseDir; |
| 875 | + |
| 876 | + public function __construct() |
| 877 | + { |
| 878 | + parent::__construct('test', false); |
| 879 | + |
| 880 | + $this->baseDir = 'foo'; |
| 881 | + } |
| 882 | + |
| 883 | + |
| 884 | + public function registerBundles() |
| 885 | + { |
| 886 | + return array(); |
| 887 | + } |
| 888 | + |
| 889 | + public function registerContainerConfiguration(LoaderInterface $loader) |
| 890 | + { |
| 891 | + } |
| 892 | + |
| 893 | + public function getProjectDir() |
| 894 | + { |
| 895 | + return $this->baseDir; |
| 896 | + } |
| 897 | + |
| 898 | + public function __destruct() |
| 899 | + { |
| 900 | + $fs = new Filesystem(); |
| 901 | + $fs->remove($this->getCacheDir()); |
| 902 | + $fs->remove($this->getLogDir()); |
| 903 | + } |
| 904 | +} |
0 commit comments