ConnectionProfiler example

$connection = $this->getMockBuilder(Connection::class)
            ->disableOriginalConstructor()
            ->getMock();
        $connection->expects(static::any())
            ->method('getDatabasePlatform')
            ->willReturn(new MySqlPlatform());
        $connection->expects(static::any())
            ->method('getConfiguration')
            ->willReturn($config);

        $collector = new ConnectionProfiler($connection);
        foreach ($queries as $queryData) {
            $query = new Query($queryData['sql'] ?? '');
            foreach (($queryData['params'] ?? []) as $key => $value) {
                if (\is_int($key)) {
                    ++$key;
                }

                $query->setValue($key$value$queryData['types'][$key] ?? ParameterType::STRING);
            }

            $query->start();

            
->method('getConfiguration')
            ->willReturn($config);

        $controller = new ProfilerController($twig$profiler$connection);

        $profile = new Profile('some-token');
        $profiler->expects(static::once())
            ->method('loadProfile')
            ->with('some-token')
            ->willReturn($profile);

        $collector = new ConnectionProfiler($connection);
        $collector->lateCollect();

        $profile->addCollector($collector);

        $response = $controller->explainAction(
            'some-token',
            'app.connection_collector',
            'default',
            5
        );

        
Home | Imprint | This part of the site doesn't use cookies.