4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests\DataCollector;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Loader\LoaderInterface;
16 use Symfony\Component\HttpFoundation\Request;
17 use Symfony\Component\HttpFoundation\Response;
18 use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
19 use Symfony\Component\HttpKernel\Kernel;
21 class ConfigDataCollectorTest extends TestCase
23 public function testCollect()
25 $kernel = new KernelForTest('test', true);
26 $c = new ConfigDataCollector();
27 $c->setKernel($kernel);
28 $c->collect(new Request(), new Response());
30 $this->assertSame('test', $c->getEnv());
31 $this->assertTrue($c->isDebug());
32 $this->assertSame('config', $c->getName());
33 $this->assertSame('testkernel', $c->getAppName());
34 $this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION);
35 $this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION);
36 $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture());
37 $this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale());
38 $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());
39 $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
40 $this->assertNull($c->getToken());
41 $this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug());
42 $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache());
43 $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), $c->hasApcu());
47 class KernelForTest extends Kernel
49 public function getName()
54 public function registerBundles()
58 public function getBundles()
63 public function registerContainerConfiguration(LoaderInterface $loader)