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
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2012-07-15 18:03:03 +01:00
|
|
|
$kernel = new KernelForTest('test', true);
|
|
|
|
$c = new ConfigDataCollector();
|
2015-02-08 19:47:12 +00:00
|
|
|
$c->setCacheVersionInfo(false);
|
2012-07-15 18:03:03 +01:00
|
|
|
$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());
|
|
|
|
$this->assertSame(PHP_VERSION, $c->getPhpVersion());
|
|
|
|
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
|
2011-03-05 23:15:01 +00:00
|
|
|
$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')) {
|
2015-05-29 18:14:48 +01:00
|
|
|
$this->assertTrue($c->hasXDebug());
|
2011-03-15 12:43:45 +00:00
|
|
|
} else {
|
2015-05-29 18:14:48 +01:00
|
|
|
$this->assertFalse($c->hasXDebug());
|
2011-03-15 12:43:45 +00:00
|
|
|
}
|
2011-03-05 23:15:01 +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'))
|
2011-03-05 23:15:01 +00:00
|
|
|
||
|
|
|
|
(extension_loaded('apc') && ini_get('apc.enabled'))
|
|
|
|
||
|
2013-04-15 05:00:45 +01:00
|
|
|
(extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
|
|
|
|
||
|
2012-09-05 09:02:54 +01:00
|
|
|
(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());
|
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
|
|
|
}
|