ConfigDataCollectorTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 dont 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 dont 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 getBundles()
  58. {
  59. return array();
  60. }
  61. public function registerContainerConfiguration(LoaderInterface $loader)
  62. {
  63. }
  64. }