<commit_before><?php

namespace Oro\Bundle\SearchBundle\Tests\Functional\EventListener;

use Doctrine\DBAL\Connection;

use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;

class UpdateSchemaListenerTest extends WebTestCase
{
    protected function setUp()
    {
        $this->initClient();

        if ($this->getContainer()->getParameter('oro_search.engine') != 'orm') {
            $this->markTestSkipped('Should be tested only with ORM search engine');
        }
    }

    /**
     * @dataProvider commandMySqlProvider
     */
    public function testCommandWithMysql($commandName, array $params, $expectedContent)
    {
        /** @var Connection $connection */
        $connection = $this->getContainer()->get('doctrine')->getConnection();
        if (false == $connection->getDatabasePlatform() instanceof MySqlPlatform) {
            $this->markTestSkipped('The test has to be run with MySql connection');
        }

        $result = $this->runCommand($commandName, $params);

        $this->assertContains($expectedContent, $result);
    }

    /**
     * @dataProvider commandPostgreSQLProvider
     */
    public function testCommandWithPostgreeSql($commandName, array $params, $expectedContent)
    {
        /** @var Connection $connection */
        $connection = $this->getContainer()->get('doctrine')->getConnection();
        if (false == $connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
            $this->markTestSkipped('The test has to be run with PostgreSql connection');
        }

        $result = $this->runCommand($commandName, $params);

        $this->assertContains($expectedContent, $result);
    }

    public function commandMySqlProvider()
    {
        return [<commit_msg>BAP-10024: Add rich text descriptions to standard entities<commit_after><?php

namespace Oro\Bundle\SearchBundle\Tests\Functional\EventListener;

use Doctrine\DBAL\Connection;

use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Oro\Bundle\TestFrameworkBundle\Test\WebTestCase;

class UpdateSchemaListenerTest extends WebTestCase
{
    protected function setUp()
    {
        $this->initClient();

        if ($this->getContainer()->getParameter('oro_search.engine') != 'orm') {
            $this->markTestSkipped('Should be tested only with ORM search engine');
        }
    }

    /**
     * @dataProvider commandMySqlProvider
     */
    public function testCommandWithMysql($commandName, array $params, $expectedContent)
    {
        /** @var Connection $connection */
        $connection = $this->getContainer()->get('doctrine')->getConnection();
        if (false == $connection->getDatabasePlatform() instanceof MySqlPlatform) {
            $this->markTestSkipped('The test has to be run with MySql connection');
        }

        $result = $this->runCommand($commandName, $params);

        $this->assertContains($expectedContent, $result);
    }

    /**
     * @dataProvider commandPostgreSQLProvider
     */
    public function testCommandWithPostgreSql($commandName, array $params, $expectedContent)
    {
        /** @var Connection $connection */
        $connection = $this->getContainer()->get('doctrine')->getConnection();
        if (false == $connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
            $this->markTestSkipped('The test has to be run with PostgreSql connection');
        }

        $result = $this->runCommand($commandName, $params);

        $this->assertContains($expectedContent, $result);
    }

    public function commandMySqlProvider()
    {
        return [
{'fraction_non_alphanumeric': 0.12520325203252033, 'fraction_numerical': 0.0013550135501355014, 'mean_word_length': 3.337250293772033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '7154944', 'n_tokens_mistral': 985, 'n_tokens_neox': 971, 'n_words': 203}