|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of php-cache organization. |
| 5 | + * |
| 6 | + * (c) 2015-2015 Aaron Scherer <[email protected]>, Tobias Nyholm <[email protected]> |
| 7 | + * |
| 8 | + * This source file is subject to the MIT license that is bundled |
| 9 | + * with this source code in the file LICENSE. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Cache\AdapterBundle\Tests\Functional\app; |
| 13 | + |
| 14 | +use Symfony\Component\Config\Loader\LoaderInterface; |
| 15 | +use Symfony\Component\Filesystem\Filesystem; |
| 16 | +use Symfony\Component\HttpKernel\Kernel; |
| 17 | + |
| 18 | +class AppKernel extends Kernel |
| 19 | +{ |
| 20 | + private $config; |
| 21 | + |
| 22 | + public function __construct($config) |
| 23 | + { |
| 24 | + parent::__construct('test', true); |
| 25 | + |
| 26 | + $fs = new Filesystem(); |
| 27 | + |
| 28 | + if (!$fs->isAbsolutePath($config)) { |
| 29 | + $config = __DIR__.'/config/'.$config; |
| 30 | + } |
| 31 | + |
| 32 | + if (!file_exists($config)) { |
| 33 | + throw new \RuntimeException(sprintf('The config file "%s" does not exist', $config)); |
| 34 | + } |
| 35 | + |
| 36 | + $this->config = $config; |
| 37 | + } |
| 38 | + |
| 39 | + public function registerBundles() |
| 40 | + { |
| 41 | + return [ |
| 42 | + new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), |
| 43 | + new \Cache\AdapterBundle\CacheAdapterBundle(), |
| 44 | + ]; |
| 45 | + } |
| 46 | + |
| 47 | + public function registerContainerConfiguration(LoaderInterface $loader) |
| 48 | + { |
| 49 | + $loader->load($this->config); |
| 50 | + } |
| 51 | + |
| 52 | + public function getCacheDir() |
| 53 | + { |
| 54 | + return sys_get_temp_dir().'/TestBundle'; |
| 55 | + } |
| 56 | + |
| 57 | + public function serialize() |
| 58 | + { |
| 59 | + return $this->config; |
| 60 | + } |
| 61 | + |
| 62 | + public function unserialize($config) |
| 63 | + { |
| 64 | + $this->__construct($config); |
| 65 | + } |
| 66 | +} |
0 commit comments