<commit_before><?php

namespace Oro\Bundle\SearchBundle\Tests\Functional\Engine\Orm;

use Oro\Bundle\EntityBundle\ORM\DatabaseDriverInterface;
use Oro\Bundle\SearchBundle\Engine\Orm\PdoPgsql;

use Doctrine\ORM\Configuration;

/**
 * @dbIsolation
 * @dbReindex
 */
class PdoPgsqlTest extends AbstractDriverTest
{
    const ENTITY_TITLE = 'test-entity-title';
    const ENVIRONMENT_NAME = 'PostgreSQL';

    public function testGetPlainSql()
    {
        $recordString = PdoPgsql::getPlainSql();
        $this->assertTrue(strpos($recordString, 'to_tsvector') > 0);
    }

    /**
     * {@inheritdoc}
     */
    public function getDriverName()
    {
        return DatabaseDriverInterface::DRIVER_POSTGRESQL;
    }

    /**
     * {@inheritdoc}
     */
    protected function getDriver()
    {
        return new PdoPgsql();
    }

    /**
     * {@inheritdoc}
     */
    protected function assertInitConfiguration(Configuration $configuration)
    {
        $this->assertEquals(
            'Oro\Bundle\SearchBundle\Engine\Orm\PdoMysql\MatchAgainst',
            $configuration->getCustomStringFunction('MATCH_AGAINST')
        );
    }

    /**
     * {@inheritdoc}
     */
    protected function assertTruncateQueries(array $queries)
    {
        $this->assertCount(7, $queries);

        $expectedQueries = [
            'SET FOREIGN_KEY_CHECKS=0',
            'TRUNCATE oro_search_item CASCADE',
            'TRUNCATE oro_search_index_text CASCADE',
            'TRUNCATE oro_search_index_integer CASCADE',
            'TRUNCATE oro_search_index_decimal CASCADE',
            'TRUNCATE oro_search_index_datetime CASCADE',
            'SET FOREIGN_KEY_CHECKS=1'
        ];

        $this->assertEquals($expectedQueries, $queries);
    }
}<commit_msg>BB-4466: Add tests - fix tests for PdoPgsql driver<commit_after><?php

namespace Oro\Bundle\SearchBundle\Tests\Functional\Engine\Orm;

use Oro\Bundle\EntityBundle\ORM\DatabaseDriverInterface;
use Oro\Bundle\SearchBundle\Engine\Orm\PdoPgsql;

use Doctrine\ORM\Configuration;

/**
 * @dbIsolation
 * @dbReindex
 */
class PdoPgsqlTest extends AbstractDriverTest
{
    const ENTITY_TITLE = 'test-entity-title';
    const ENVIRONMENT_NAME = 'PostgreSQL';

    public function testGetPlainSql()
    {
        $recordString = PdoPgsql::getPlainSql();
        $this->assertTrue(strpos($recordString, 'to_tsvector') > 0);
    }

    /**
     * {@inheritdoc}
     */
    public function getDriverName()
    {
        return DatabaseDriverInterface::DRIVER_POSTGRESQL;
    }

    /**
     * {@inheritdoc}
     */
    protected function getDriver()
    {
        return new PdoPgsql();
    }

    /**
     * {@inheritdoc}
     */
    protected function assertInitConfiguration(Configuration $configuration)
    {
        $this->assertEquals(
            'Oro\Bundle\SearchBundle\Engine\Orm\PdoPgsql\TsRank',
            $configuration->getCustomStringFunction('TsRank')
        );

        $this->assertEquals(
            'Oro\Bundle\SearchBundle\Engine\Orm\PdoPgsql\TsvectorTsquery',
            $configuration->getCustomStringFunction('TsvectorTsquery')
        );
    }

    /**
     * {@inheritdoc}
     */
    protected function assertTruncateQueries(array $queries)
    {
        $this->assertCount(5, $queries);

        $expectedQueries = [
            'TRUNCATE oro_search_item CASCADE',
            'TRUNCATE oro_search_index_text CASCADE',
            'TRUNCATE oro_search_index_integer CASCADE',
            'TRUNCATE oro_search_index_decimal CASCADE',
            'TRUNCATE oro_search_index_datetime CASCADE'
        ];

        $this->assertEquals($expectedQueries, $queries);
    }
}
{'fraction_non_alphanumeric': 0.11281910513313204, 'fraction_numerical': 0.002744990392533626, 'mean_word_length': 2.6586345381526106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6745463', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1145, 'n_words': 164}