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

82 lines
2.4 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;
use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ConfigDataCollectorTest extends \PHPUnit_Framework_TestCase
{
public function testCollect()
{
$kernel = new KernelForTest('test', true);
$c = new ConfigDataCollector();
$c->setCacheVersionInfo(false);
$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->assertSame('testkernel', $c->getAppName());
$this->assertSame(PHP_VERSION, $c->getPhpVersion());
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
$this->assertNull($c->getToken());
2011-03-15 12:43:45 +00:00
2011-06-12 21:52:53 +01:00
// if else clause because we don't know it
2011-03-15 12:43:45 +00:00
if (extension_loaded('xdebug')) {
$this->assertTrue($c->hasXDebug());
2011-03-15 12:43:45 +00:00
} else {
$this->assertFalse($c->hasXDebug());
2011-03-15 12:43:45 +00:00
}
2011-06-12 21:52:53 +01:00
// if else clause because we don't know it
2011-03-15 12:43:45 +00:00
if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
||
(extension_loaded('apc') && ini_get('apc.enabled'))
||
(extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
||
(extension_loaded('xcache') && ini_get('xcache.cacher'))
||
(extension_loaded('wincache') && ini_get('wincache.ocenabled')))) {
2011-03-15 12:43:45 +00:00
$this->assertTrue($c->hasAccelerator());
} else {
$this->assertFalse($c->hasAccelerator());
}
}
}
class KernelForTest extends Kernel
{
public function getName()
{
return 'testkernel';
}
2011-03-15 12:43:45 +00:00
public function registerBundles()
{
}
2011-03-15 12:43:45 +00:00
public function getBundles()
{
return array();
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
}
2011-03-15 12:43:45 +00:00
}