b6dfb70c1b6224ea24df90d1226a3a85c311e3df
[yaffs-website] / vendor / symfony / http-kernel / Tests / DataCollector / ConfigDataCollectorTest.php
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
12 namespace Symfony\Component\HttpKernel\Tests\DataCollector;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector;
16 use Symfony\Component\HttpKernel\Kernel;
17 use Symfony\Component\Config\Loader\LoaderInterface;
18 use Symfony\Component\HttpFoundation\Request;
19 use Symfony\Component\HttpFoundation\Response;
20
21 class ConfigDataCollectorTest extends TestCase
22 {
23     public function testCollect()
24     {
25         $kernel = new KernelForTest('test', true);
26         $c = new ConfigDataCollector();
27         $c->setCacheVersionInfo(false);
28         $c->setKernel($kernel);
29         $c->collect(new Request(), new Response());
30
31         $this->assertSame('test', $c->getEnv());
32         $this->assertTrue($c->isDebug());
33         $this->assertSame('config', $c->getName());
34         $this->assertSame('testkernel', $c->getAppName());
35         $this->assertSame(PHP_VERSION, $c->getPhpVersion());
36         $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
37         $this->assertNull($c->getToken());
38
39         // if else clause because we don't know it
40         if (extension_loaded('xdebug')) {
41             $this->assertTrue($c->hasXDebug());
42         } else {
43             $this->assertFalse($c->hasXDebug());
44         }
45
46         // if else clause because we don't know it
47         if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
48                 ||
49                 (extension_loaded('apc') && ini_get('apc.enabled'))
50                 ||
51                 (extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
52                 ||
53                 (extension_loaded('xcache') && ini_get('xcache.cacher'))
54                 ||
55                 (extension_loaded('wincache') && ini_get('wincache.ocenabled')))) {
56             $this->assertTrue($c->hasAccelerator());
57         } else {
58             $this->assertFalse($c->hasAccelerator());
59         }
60     }
61 }
62
63 class KernelForTest extends Kernel
64 {
65     public function getName()
66     {
67         return 'testkernel';
68     }
69
70     public function registerBundles()
71     {
72     }
73
74     public function getBundles()
75     {
76         return array();
77     }
78
79     public function registerContainerConfiguration(LoaderInterface $loader)
80     {
81     }
82 }