No Description

ConfigDataCollectorTest.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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\Component\HttpKernel\Tests\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();
  22. $c->setKernel($kernel);
  23. $c->collect(new Request(), new Response());
  24. $this->assertSame('test', $c->getEnv());
  25. $this->assertTrue($c->isDebug());
  26. $this->assertSame('config', $c->getName());
  27. $this->assertSame('testkernel', $c->getAppName());
  28. $this->assertSame(PHP_VERSION, $c->getPhpVersion());
  29. $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
  30. $this->assertNull($c->getToken());
  31. // if else clause because we don't know it
  32. if (extension_loaded('xdebug')) {
  33. $this->assertTrue($c->hasXDebug());
  34. } else {
  35. $this->assertFalse($c->hasXDebug());
  36. }
  37. // if else clause because we don't know it
  38. if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
  39. ||
  40. (extension_loaded('apc') && ini_get('apc.enabled'))
  41. ||
  42. (extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
  43. ||
  44. (extension_loaded('xcache') && ini_get('xcache.cacher'))
  45. ||
  46. (extension_loaded('wincache') && ini_get('wincache.ocenabled')))) {
  47. $this->assertTrue($c->hasAccelerator());
  48. } else {
  49. $this->assertFalse($c->hasAccelerator());
  50. }
  51. }
  52. }
  53. class KernelForTest extends Kernel
  54. {
  55. public function getName()
  56. {
  57. return 'testkernel';
  58. }
  59. public function registerBundles()
  60. {
  61. }
  62. public function getBundles()
  63. {
  64. return array();
  65. }
  66. public function registerContainerConfiguration(LoaderInterface $loader)
  67. {
  68. }
  69. }