1<?php 2 3/* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Symfony\Component\HttpKernel\Tests\DataCollector; 13 14use PHPUnit\Framework\TestCase; 15use Symfony\Component\Config\Loader\LoaderInterface; 16use Symfony\Component\HttpFoundation\Request; 17use Symfony\Component\HttpFoundation\Response; 18use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector; 19use Symfony\Component\HttpKernel\Kernel; 20 21class ConfigDataCollectorTest extends TestCase 22{ 23 public function testCollect() 24 { 25 $kernel = new KernelForTest('test', true); 26 $c = new ConfigDataCollector(); 27 $c->setKernel($kernel); 28 $c->collect(new Request(), new Response()); 29 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->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', \PHP_VERSION); 35 $this->assertMatchesRegularExpression('~'.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()); 44 } 45} 46 47class KernelForTest extends Kernel 48{ 49 public function getName() 50 { 51 return 'testkernel'; 52 } 53 54 public function registerBundles() 55 { 56 } 57 58 public function getBundles() 59 { 60 return []; 61 } 62 63 public function registerContainerConfiguration(LoaderInterface $loader) 64 { 65 } 66} 67