/Tests/Kernel.php

http://github.com/FriendsOfSymfony/FOSFacebookBundle · PHP · 71 lines · 51 code · 12 blank · 8 comment · 2 complexity · f1872ddeb46cf07f1092776770455476 MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of the FOSFacebookBundle package.
  4. *
  5. * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace FOS\FacebookBundle\Tests;
  11. use Symfony\Component\HttpKernel\Kernel as BaseKernel;
  12. use Symfony\Component\Config\Loader\LoaderInterface;
  13. use Symfony\Component\Filesystem\Filesystem;
  14. use Symfony\Component\ClassLoader\UniversalClassLoader;
  15. class Kernel extends BaseKernel
  16. {
  17. public function __construct()
  18. {
  19. $this->tmpDir = sys_get_temp_dir().'/sf2_'.rand(1, 9999);
  20. if (!is_dir($this->tmpDir)) {
  21. if (false === @mkdir($this->tmpDir)) {
  22. die(sprintf('Unable to create a temporary directory (%s)', $this->tmpDir));
  23. }
  24. } elseif (!is_writable($this->tmpDir)) {
  25. die(sprintf('Unable to write in a temporary directory (%s)', $this->tmpDir));
  26. }
  27. parent::__construct('env', true);
  28. require_once __DIR__.'/FacebookApiException.php';
  29. $loader = new UniversalClassLoader();
  30. $loader->loadClass('\FacebookApiException');
  31. $loader->register();
  32. }
  33. public function __destruct()
  34. {
  35. $fs = new Filesystem();
  36. $fs->remove($this->tmpDir);
  37. }
  38. public function registerRootDir()
  39. {
  40. return $this->tmpDir;
  41. }
  42. public function registerBundles()
  43. {
  44. return array(
  45. new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
  46. );
  47. }
  48. public function registerBundleDirs()
  49. {
  50. return array(
  51. );
  52. }
  53. public function registerContainerConfiguration(LoaderInterface $loader)
  54. {
  55. $loader->load(function ($container) {
  56. $container->setParameter('kernel.compiled_classes', array());
  57. });
  58. }
  59. }