This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php

77 lines
3.1 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
2017-02-08 07:24:27 +00:00
use PHPUnit\Framework\TestCase;
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;
2017-02-08 07:24:27 +00:00
class ConfigDataCollectorTest extends TestCase
{
public function testCollect()
{
$kernel = new KernelForTest('test', true);
$c = new ConfigDataCollector();
$c->setKernel($kernel);
$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());
$this->assertTrue($c->isDebug());
2014-12-02 19:42:47 +00:00
$this->assertSame('config', $c->getName());
$this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION);
$this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION);
$this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture());
$this->assertSame(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale());
$this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());
2014-12-02 19:42:47 +00:00
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
$this->assertNull($c->getToken());
$this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug());
$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());
}
/**
* @group legacy
* @expectedDeprecation The "$name" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2.
* @expectedDeprecation The "$version" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2.
* @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationName()" is deprecated since Symfony 4.2.
* @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationVersion()" is deprecated since Symfony 4.2.
*/
public function testLegacy()
{
$c = new ConfigDataCollector('name', null);
$c->collect(new Request(), new Response());
$this->assertSame('name', $c->getApplicationName());
$this->assertNull($c->getApplicationVersion());
}
}
2011-03-15 12:43:45 +00:00
class KernelForTest extends Kernel
{
2011-03-15 12:43:45 +00:00
public function registerBundles()
{
}
2011-03-15 12:43:45 +00:00
public function getBundles()
{
2019-01-16 09:39:14 +00:00
return [];
2011-03-15 12:43:45 +00:00
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
}
2011-03-15 12:43:45 +00:00
}