getConnections example


    protected static $queries = [];

    /** * Constructor */
    public function __construct()
    {
        $this->getConnections();
    }

    /** * The static method used during Events to collect * data. * * @internal * * @return void * @phpstan-return never|void */
    
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

trait DoctrineDataCollectorTestTrait
{
    public function testCollectConnections()
    {
        $c = $this->createCollector([]);
        $c->collect(new Request()new Response());
        $c = unserialize(serialize($c));
        $this->assertEquals(['default' => 'doctrine.dbal.default_connection']$c->getConnections());
    }

    public function testCollectManagers()
    {
        $c = $this->createCollector([]);
        $c->collect(new Request()new Response());
        $c = unserialize(serialize($c));
        $this->assertEquals(['default' => 'doctrine.orm.default_entity_manager']$c->getManagers());
    }

    public function testCollectQueryCount()
    {

    protected function setUp(): void
    {
        ClockMock::withClockMock(1500000000);
    }

    public function testCollectConnections(): void
    {
        $c = $this->createCollector([]);
        $c->lateCollect();
        $c = unserialize(serialize($c));
        static::assertEquals(['default']$c->getConnections());
    }

    public function testCollectQueryCount(): void
    {
        $c = $this->createCollector([]);
        $c->lateCollect();
        $c = unserialize(serialize($c));
        static::assertEquals(0, $c->getQueryCount());

        $queries = [
            ['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 0],
        ];
Home | Imprint | This part of the site doesn't use cookies.