<commit_before><?php
namespace CsvMigrations\Test\TestCase;

use Cake\Core\Configure;
use CsvMigrations\MigrationTrait;
use PHPUnit_Framework_TestCase;

class MigrationTraitTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        parent::setUp();
        $this->mock = $this->getMockForTrait(MigrationTrait::class);

        $dir = dirname(__DIR__) . DS . 'data' . DS . 'CsvMigrations' . DS . 'migrations' . DS;
        Configure::write('CsvMigrations.migrations.path', $dir);
    }

    /**
     * @dataProvider csvProvider
     */
    public function testGetFieldsDefinitions($name, $expected)
    {
        $this->assertEquals($expected, $this->mock->getFieldsDefinitions($name));
    }

    /**
     * @expectedException RuntimeException
     */
    public function testGetFieldsDefinitionsThrowsException()
    {
        $this->mock->getFieldsDefinitions();
    }

    public function csvProvider()
    {
        return [
            [
                'WrongName',
                []
            ],
            [
                'Foo',
                [
                    'id' => [
                        'name' => 'id',
                        'type' => 'uuid',
                        'required' => '',
                        'non-searchable' => '',
                        'unique' => false
                    ],
                    'description' => [
                        'name' => 'description',
                        'type' => 'text',
                        'required' => '',
                        'non-searchable' => true,
                        'unique' => false
                    ],
                    'name' => [
                        'name' => 'name',
                        'type' => 'string',
                        'required' => '1',
                        'non-searchable' => '',
                        'unique' => true
                    ],
                    'status' => [
                        'name' => 'status',
                        'type' => 'list(foo_statuses)',
                        'required' => '1',<commit_msg>Fixed unit test (task #2833)<commit_after><?php
namespace CsvMigrations\Test\TestCase;

use Cake\Core\Configure;
use CsvMigrations\MigrationTrait;
use PHPUnit_Framework_TestCase;

class MigrationTraitTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        parent::setUp();
        $this->mock = $this->getMockForTrait(MigrationTrait::class);

        $dir = dirname(__DIR__) . DS . 'data' . DS . 'CsvMigrations' . DS . 'migrations' . DS;
        Configure::write('CsvMigrations.migrations.path', $dir);
    }

    /**
     * @dataProvider csvProvider
     */
    public function testGetFieldsDefinitions($name, $expected)
    {
        $this->assertEquals($expected, $this->mock->getFieldsDefinitions($name));
    }

    /**
     * @expectedException RuntimeException
     */
    public function testGetFieldsDefinitionsThrowsException()
    {
        $this->mock->getFieldsDefinitions();
    }

    public function csvProvider()
    {
        return [
            [
                'Foo',
                [
                    'id' => [
                        'name' => 'id',
                        'type' => 'uuid',
                        'required' => '',
                        'non-searchable' => '',
                        'unique' => false
                    ],
                    'description' => [
                        'name' => 'description',
                        'type' => 'text',
                        'required' => '',
                        'non-searchable' => true,
                        'unique' => false
                    ],
                    'name' => [
                        'name' => 'name',
                        'type' => 'string',
                        'required' => '1',
                        'non-searchable' => '',
                        'unique' => true
                    ],
                    'status' => [
                        'name' => 'status',
                        'type' => 'list(foo_statuses)',
                        'required' => '1',
{'fraction_non_alphanumeric': 0.13260869565217392, 'fraction_numerical': 0.001932367149758454, 'mean_word_length': 1.1714735186156267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '4213126', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1011, 'n_words': 174}