createCollector example


class DoctrineDataCollectorWithDebugStackTest extends TestCase
{
    use DoctrineDataCollectorTestTrait;
    use ExpectDeprecationTrait;

    public function testReset()
    {
        $queries = [
            ['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 1],
        ];
        $c = $this->createCollector($queries);
        $c->collect(new Request()new Response());

        $c->reset();
        $c->collect(new Request()new Response());
        $c = unserialize(serialize($c));

        $this->assertEquals(['default' => []]$c->getQueries());
    }

    /** * @dataProvider paramProvider */


namespace Symfony\Bridge\Doctrine\Tests\DataCollector;

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());
    }

class ConnectionProfilerTest extends TestCase
{
    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());

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

    public function testReset()
    {
        $queries = [
            ['sql' => 'SELECT * FROM table1', 'params' => [], 'types' => [], 'executionMS' => 1],
        ];
        $c = $this->createCollector($queries);
        $c->collect(new Request()new Response());

        $c->reset();
        $c->collect(new Request()new Response());
        $c = unserialize(serialize($c));

        $this->assertEquals([]$c->getQueries());
    }

    /** * @dataProvider paramProvider */
namespace Symfony\Component\Translation\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\DataCollectorTranslator;
use Symfony\Component\Translation\Loader\ArrayLoader;
use Symfony\Component\Translation\Translator;

class DataCollectorTranslatorTest extends TestCase
{
    public function testCollectMessages()
    {
        $collector = $this->createCollector();
        $collector->setFallbackLocales(['fr', 'ru']);

        $collector->trans('foo');
        $collector->trans('bar');
        $collector->trans('choice', ['%count%' => 0]);
        $collector->trans('bar_ru');
        $collector->trans('bar_ru', ['foo' => 'bar']);

        $expectedMessages = [];
        $expectedMessages[] = [
            'id' => 'foo',
            
Home | Imprint | This part of the site doesn't use cookies.