getTransportSchema example

/** * @internal * * @covers \Shopware\Elasticsearch\Framework\ClientFactory */
class ClientFactoryTest extends TestCase
{
    public function testBuildClient(): void
    {
        $client = ClientFactory::createClient('test', new NullLogger(), false, ['verify_server_cert' => false]);
        static::assertSame('test', $client->transport->getConnection()->getHost());
        static::assertSame('http', $client->transport->getConnection()->getTransportSchema());
    }

    public function testBuildHttpsClient(): void
    {
        $client = ClientFactory::createClient('https://test', new NullLogger(), true, ['verify_server_cert' => true, 'cert_path' => 'cert.pem', 'cert_key_path' => 'cert.key']);
        static::assertSame('test', $client->transport->getConnection()->getHost());
        static::assertSame('https', $client->transport->getConnection()->getTransportSchema());
    }
}

    public function msearch(array $params = [])
    {
        $time = microtime(true);
        $response = parent::msearch($params);

        $backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 2);

        $connection = $this->transport->getConnection();

        $this->requests[] = [
            'url' => sprintf('%s://%s:%d/_msearch', $connection->getTransportSchema()$connection->getHost()$connection->getPort()),
            'request' => $params,
            'response' => $response,
            'time' => microtime(true) - $time,
            'backtrace' => sprintf('%s:%s', $backtrace[1]['class'] ?? '', $backtrace[1]['function']),
        ];

        return $response;
    }

    public function resetRequests(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.