/Tests/Kernel.php
PHP | 71 lines | 51 code | 12 blank | 8 comment | 2 complexity | f1872ddeb46cf07f1092776770455476 MD5 | raw file
1<?php 2 3/* 4 * This file is part of the FOSFacebookBundle package. 5 * 6 * (c) FriendsOfSymfony <http://friendsofsymfony.github.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 12namespace FOS\FacebookBundle\Tests; 13 14use Symfony\Component\HttpKernel\Kernel as BaseKernel; 15use Symfony\Component\Config\Loader\LoaderInterface; 16use Symfony\Component\Filesystem\Filesystem; 17use Symfony\Component\ClassLoader\UniversalClassLoader; 18 19class Kernel extends BaseKernel 20{ 21 public function __construct() 22 { 23 $this->tmpDir = sys_get_temp_dir().'/sf2_'.rand(1, 9999); 24 if (!is_dir($this->tmpDir)) { 25 if (false === @mkdir($this->tmpDir)) { 26 die(sprintf('Unable to create a temporary directory (%s)', $this->tmpDir)); 27 } 28 } elseif (!is_writable($this->tmpDir)) { 29 die(sprintf('Unable to write in a temporary directory (%s)', $this->tmpDir)); 30 } 31 32 parent::__construct('env', true); 33 34 require_once __DIR__.'/FacebookApiException.php'; 35 36 $loader = new UniversalClassLoader(); 37 $loader->loadClass('\FacebookApiException'); 38 $loader->register(); 39 } 40 41 public function __destruct() 42 { 43 $fs = new Filesystem(); 44 $fs->remove($this->tmpDir); 45 } 46 47 public function registerRootDir() 48 { 49 return $this->tmpDir; 50 } 51 52 public function registerBundles() 53 { 54 return array( 55 new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 56 ); 57 } 58 59 public function registerBundleDirs() 60 { 61 return array( 62 ); 63 } 64 65 public function registerContainerConfiguration(LoaderInterface $loader) 66 { 67 $loader->load(function ($container) { 68 $container->setParameter('kernel.compiled_classes', array()); 69 }); 70 } 71}