ConfigDataCollectorTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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 Symfony\Tests\Component\HttpKernel\DataCollector;
  11. use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
  12. use Symfony\Component\HttpKernel\Kernel;
  13. use Symfony\Component\Config\Loader\LoaderInterface;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. class ConfigDataCollectorTest extends \PHPUnit_Framework_TestCase
  17. {
  18. public function testCollect()
  19. {
  20. $kernel = new KernelForTest('test',true);
  21. $c = new ConfigDataCollector($kernel);
  22. $c->collect(new Request(), new Response());
  23. $this->assertSame('test',$c->getEnv());
  24. $this->assertTrue($c->isDebug());
  25. $this->assertSame('config',$c->getName());
  26. $this->assertSame('testkernel',$c->getAppName());
  27. $this->assertSame(PHP_VERSION,$c->getPhpVersion());
  28. $this->assertSame(Kernel::VERSION,$c->getSymfonyVersion());
  29. $this->assertNull($c->getToken());
  30. // if else clause because we don't know it
  31. if (extension_loaded('xdebug')) {
  32. $this->assertTrue($c->hasXdebug());
  33. } else {
  34. $this->assertFalse($c->hasXdebug());
  35. }
  36. // if else clause because we don't know it
  37. if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
  38. ||
  39. (extension_loaded('apc') && ini_get('apc.enabled'))
  40. ||
  41. (extension_loaded('xcache') && ini_get('xcache.cacher')))) {
  42. $this->assertTrue($c->hasAccelerator());
  43. } else {
  44. $this->assertFalse($c->hasAccelerator());
  45. }
  46. }
  47. }
  48. class KernelForTest extends Kernel
  49. {
  50. public function getName()
  51. {
  52. return 'testkernel';
  53. }
  54. public function registerBundles()
  55. {
  56. }
  57. public function init()
  58. {
  59. }
  60. public function getBundles()
  61. {
  62. return array();
  63. }
  64. public function registerContainerConfiguration(LoaderInterface $loader)
  65. {
  66. }
  67. }