<commit_before><?php

/**
 * @package ModelGenerator
 * @author <NAME> <EMAIL>
 * @license MIT
 * @link http://www.github.com/thytanium/model-generator
 */
class ModelGeneratorTest extends TestCase
{
    /**
     * Test that main object is present
     * @return void
     */
    public function testIsPresent()
    {
        $this->assertTrue(!is_null($this->generator));
    }

    /**
     * Test first migration file
     * @dataProvider migrationProvider
     * @param $migrationsPath
     * @param $expectedModels
     * @param $oneToOne
     * @param $oneToMany
     * @param $pivots
     * @param $variation
     * @return void
     */
    public function testMigrations($migrationsPath, $expectedModels, $oneToOne, $oneToMany, $pivots, $variation)
    {
        //First round, read migrations
        $this->generator->firstRound($this->getMigrationsPath().$migrationsPath);

        //Relations
        $this->generator->pivots = $pivots;
        $this->generator->oneToOne = $oneToOne;
        $this->generator->oneToMany = $oneToMany;

        //Second round, process relations, create models
        $this->generator->secondRound($this->getModelsPath(), "App", true);

        //Check that files were created
        foreach ($expectedModels as $model) {
            $this->assertTrue($this->file->exists($this->getModelsPath()."{$model}.php"));

            //Check their contents are what are supposed to be
            $file1 = $this->file->get($this->getModelsPath().$model.".php");
            $file2 = $this->file->get($this->getModelsPath().$migrationsPath."variation{$variation}/{$model}.txt");
            $this->assertEquals($file1, $file2);
        }
    }

    /**
     * Migration provider
     * @return array
     */
    public function migrationProvider()
    {
        $data = [];

        //Migration 001 / Variation 1
        $expectedModels = ['User', 'UserGroup'];
        $pivots = [[['user', 'user_group']]];
        $oneToOne = [];
        $oneToMany = [];
        $data[] = ['migration001/', $expectedModels, $oneToOne, $oneToMany, $pivots, 1];

        //Migration 001 / Variation 2
        $expectedModels = ['User', 'UserGroup'];
        $pivots = [];
        $oneToOne = [];
        $oneToMany = [];
        $data[] = ['migration001/', $expectedModels, $oneToOne, $oneToMany, $pivots, 2];

        return $data;<commit_msg>Fixing test<commit_after><?php

/**
 * @package ModelGenerator
 * @author <NAME> <EMAIL>
 * @license MIT
 * @link http://www.github.com/thytanium/model-generator
 */
class ModelGeneratorTest extends TestCase
{
    /**
     * Test that main object is present
     * @return void
     */
    public function testIsPresent()
    {
        $this->assertTrue(!is_null($this->generator));
    }

    /**
     * Test first migration file
     * @dataProvider migrationProvider
     * @param $migrationsPath
     * @param $expectedModels
     * @param $oneToOne
     * @param $oneToMany
     * @param $pivots
     * @param $variation
     * @return void
     */
    public function testMigrations($migrationsPath, $expectedModels, $oneToOne, $oneToMany, $pivots, $variation)
    {
        //First round, read migrations
        $this->generator->firstRound($this->getMigrationsPath().$migrationsPath);

        //Relations
        $this->generator->pivots = $pivots;
        $this->generator->oneToOne = $oneToOne;
        $this->generator->oneToMany = $oneToMany;

        //Second round, process relations, create models
        $this->generator->secondRound($this->getModelsPath(), "App", true);

        //Check that files were created
        foreach ($expectedModels as $model) {
            $this->assertTrue($this->file->exists($this->getModelsPath()."{$model}.php"));

            //Check their contents are what are supposed to be
            $file1 = $this->file->get($this->getModelsPath().$model.".php");
            $file2 = $this->file->get($this->getModelsPath().$migrationsPath."variation{$variation}/{$model}.txt");
            $this->assertEquals($file1, $file2);
        }
    }

    /**
     * Migration provider
     * @return array
     */
    public function migrationProvider()
    {
        $data = [];

        //Migration 001 / Variation 1
        $expectedModels = ['User', 'UserGroup'];
        $pivots = [[['user', 'user_group']]];
        $oneToOne = [];
        $oneToMany = [];
        $data[] = ['migration001/', $expectedModels, $oneToOne, $oneToMany, $pivots, 1];

        //Migration 001 / Variation 2
        $pivots = [];
        $data[] = ['migration001/', $expectedModels, $oneToOne, $oneToMany, $pivots, 2];

        return $data;
{'fraction_non_alphanumeric': 0.15853131749460042, 'fraction_numerical': 0.008639308855291577, 'mean_word_length': 2.5030257186081695, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4796518', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1376, 'n_words': 287}