<commit_before><?php

namespace Phase\TakeATicket;

use /** @noinspection PhpInternalEntityUsedInspection */
    Doctrine\DBAL\Configuration; // PHPStorm warning quirk
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Phase\TakeATicket\DataSource\Factory;

class DataSourceTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \Doctrine\DBAL\Connection[]
     * Loaded on demand by ::getConfiguredDatabases
     */
    protected $databases = false;

    public function setUp()
    {
        $databases = $this->getConfiguredDatabases();

        $sqlDir = dirname(dirname(dirname(__DIR__))) . '/sql/';

        $sqlSourceFiles = [];
        $sqlSourceFiles['mysql'] = $sqlDir . 'db-mysql.sql';
        $sqlSourceFiles['sqlite'] = $sqlDir . 'db-sqlite.sql';

        $songSqlFile = $sqlDir . 'sampleSongs.sql';
        $songInserts = file($songSqlFile);

        $this->assertTrue(is_array($songInserts) && count($songInserts), 'Sample songs required');

        foreach ($sqlSourceFiles as $k => $v) {
            $sqlClauses = $this->schemaFileToClauses($v);

            if (isset($databases[$k])) {
                foreach ($sqlClauses as $sql) {
                    $databases[$k]->exec($sql);
                }

                foreach ($songInserts as $insertSql) {
                    if ($insertSql && !preg_match('/^\s+-- /', $insertSql)) {
                        $databases[$k]->exec($insertSql);
                    }
                }
            }
        }
    }

    /**
     * @dataProvider databasesProvider
     * @param string $dbName
     * @param Connection $conn
     */
    public function testSearch($dbName, $conn)
    {
        $searchString = 'When you';
        // should return The Killers: When You Were Young

        print("Test search for DB: $dbName\n");
        $dataSource = Factory::datasourceFromDbConnection($conn);<commit_msg>Remove debug<commit_after><?php

namespace Phase\TakeATicket;

use /** @noinspection PhpInternalEntityUsedInspection */
    Doctrine\DBAL\Configuration; // PHPStorm warning quirk
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Phase\TakeATicket\DataSource\Factory;

class DataSourceTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \Doctrine\DBAL\Connection[]
     * Loaded on demand by ::getConfiguredDatabases
     */
    protected $databases = false;

    public function setUp()
    {
        $databases = $this->getConfiguredDatabases();

        $sqlDir = dirname(dirname(dirname(__DIR__))) . '/sql/';

        $sqlSourceFiles = [];
        $sqlSourceFiles['mysql'] = $sqlDir . 'db-mysql.sql';
        $sqlSourceFiles['sqlite'] = $sqlDir . 'db-sqlite.sql';

        $songSqlFile = $sqlDir . 'sampleSongs.sql';
        $songInserts = file($songSqlFile);

        $this->assertTrue(is_array($songInserts) && count($songInserts), 'Sample songs required');

        foreach ($sqlSourceFiles as $k => $v) {
            $sqlClauses = $this->schemaFileToClauses($v);

            if (isset($databases[$k])) {
                foreach ($sqlClauses as $sql) {
                    $databases[$k]->exec($sql);
                }

                foreach ($songInserts as $insertSql) {
                    if ($insertSql && !preg_match('/^\s+-- /', $insertSql)) {
                        $databases[$k]->exec($insertSql);
                    }
                }
            }
        }
    }

    /**
     * @dataProvider databasesProvider
     * @param string $dbName
     * @param Connection $conn
     */
    public function testSearch($dbName, $conn)
    {
        $searchString = 'When you';
        // should return The Killers: When You Were Young

        $dataSource = Factory::datasourceFromDbConnection($conn);
{'fraction_non_alphanumeric': 0.13693500936079164, 'fraction_numerical': 0.0, 'mean_word_length': 2.2578397212543555, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '2223747', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1064, 'n_words': 211}