2011-03-05 23:15:01 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-03-05 23:15:01 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2012-03-28 14:43:52 +01:00
|
|
|
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
|
2011-03-05 23:15:01 +00:00
|
|
|
|
2017-02-08 07:24:27 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2011-03-05 23:15:01 +00:00
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2018-07-26 10:03:18 +01:00
|
|
|
use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
|
|
|
|
use Symfony\Component\HttpKernel\Kernel;
|
2011-03-05 23:15:01 +00:00
|
|
|
|
2017-02-08 07:24:27 +00:00
|
|
|
class ConfigDataCollectorTest extends TestCase
|
2011-03-05 23:15:01 +00:00
|
|
|
{
|
|
|
|
public function testCollect()
|
|
|
|
{
|
2012-07-15 18:03:03 +01:00
|
|
|
$kernel = new KernelForTest('test', true);
|
|
|
|
$c = new ConfigDataCollector();
|
|
|
|
$c->setKernel($kernel);
|
2011-03-05 23:15:01 +00:00
|
|
|
$c->collect(new Request(), new Response());
|
2011-03-15 12:43:45 +00:00
|
|
|
|
2014-12-02 19:42:47 +00:00
|
|
|
$this->assertSame('test', $c->getEnv());
|
2011-03-05 23:15:01 +00:00
|
|
|
$this->assertTrue($c->isDebug());
|
2014-12-02 19:42:47 +00:00
|
|
|
$this->assertSame('config', $c->getName());
|
|
|
|
$this->assertSame('testkernel', $c->getAppName());
|
2016-12-17 14:14:25 +00:00
|
|
|
$this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION);
|
|
|
|
$this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION);
|
2016-11-30 12:01:25 +00:00
|
|
|
$this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture());
|
2016-12-18 18:57:23 +00:00
|
|
|
$this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale());
|
2016-11-30 12:01:25 +00:00
|
|
|
$this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());
|
2014-12-02 19:42:47 +00:00
|
|
|
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
|
2011-03-05 23:15:01 +00:00
|
|
|
$this->assertNull($c->getToken());
|
2018-07-26 09:45:46 +01:00
|
|
|
$this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug());
|
2018-10-31 09:06:03 +00:00
|
|
|
$this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)), $c->hasZendOpcache());
|
|
|
|
$this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN)), $c->hasApcu());
|
2011-03-05 23:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class KernelForTest extends Kernel
|
|
|
|
{
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'testkernel';
|
|
|
|
}
|
2011-03-15 12:43:45 +00:00
|
|
|
|
|
|
|
public function registerBundles()
|
|
|
|
{
|
2011-03-05 23:15:01 +00:00
|
|
|
}
|
2011-03-15 12:43:45 +00:00
|
|
|
|
|
|
|
public function getBundles()
|
|
|
|
{
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader)
|
|
|
|
{
|
2011-03-05 23:15:01 +00:00
|
|
|
}
|
2011-03-15 12:43:45 +00:00
|
|
|
}
|