File: ProfilerTest.php

package info (click to toggle)
symfony 5.4.23%2Bdfsg-1%2Bdeb12u4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,212 kB
  • sloc: php: 845,908; xml: 5,982; sh: 590; javascript: 578; makefile: 155; pascal: 84
file content (66 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?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\Bundle\FrameworkBundle\Tests\Functional;

class ProfilerTest extends AbstractWebTestCase
{
    /**
     * @dataProvider getConfigs
     */
    public function testProfilerIsDisabled($insulate)
    {
        $client = $this->createClient(['test_case' => 'Profiler', 'root_config' => 'config.yml']);
        if ($insulate) {
            $client->insulate();
        }

        $client->request('GET', '/profiler');
        $this->assertNull($client->getProfile());

        // enable the profiler for the next request
        $client->enableProfiler();
        $this->assertNull($client->getProfile());
        $client->request('GET', '/profiler');
        $this->assertIsObject($client->getProfile());

        $client->request('GET', '/profiler');
        $this->assertNull($client->getProfile());
    }

    /**
     * @dataProvider getConfigs
     */
    public function testProfilerCollectParameter($insulate)
    {
        $client = $this->createClient(['test_case' => 'ProfilerCollectParameter', 'root_config' => 'config.yml']);
        if ($insulate) {
            $client->insulate();
        }

        $client->request('GET', '/profiler');
        $this->assertNull($client->getProfile());

        // enable the profiler for the next request
        $client->request('GET', '/profiler?profile=1');
        $this->assertIsObject($client->getProfile());

        $client->request('GET', '/profiler');
        $this->assertNull($client->getProfile());
    }

    public static function getConfigs()
    {
        return [
            [false],
        ];
    }
}