<commit_before><?php

use Mockery as m;
use Illuminate\Database\Schema;

class IseedTest extends PHPUnit_Framework_TestCase {

    protected static $stubsDir, $testStubsDir;

    public function __construct()
    {
        static::$stubsDir = __DIR__.'/../src/Orangehill/Iseed/Stubs';
        static::$testStubsDir = __DIR__.'/Stubs';
    }

    public function tearDown()
    {
        m::close();
    }

    public function testPopulatesStub()
    {
        $productionStub = file_get_contents(static::$stubsDir . '/seed.stub');
        $iseed = new Orangehill\Iseed\Iseed();
        $output = $iseed->populateStub('test_class', $productionStub, 'test_table', 'test_data');
        $expected = file_get_contents(static::$testStubsDir . '/seed.stub');
        $this->assertEquals($expected, $output);
    }

    /**
     * @expectedException Orangehill\Iseed\TableNotFoundException
     * @expectedExceptionMessage Table nonexisting was not found.
     */
    public function testTableNotFoundException()
    {
        $hasTable = m::mock('Orangehill\Iseed\Iseed[hasTable]');
        $hasTable->shouldReceive('hasTable')->once()->andReturn(false);
        $hasTable->generateSeed('nonexisting');
    }

    public function testRepacksSeedData()
    {
        $data = array(
            array('id' => '1', 'name' => 'one'),
            array('id' => '2', 'name' => 'two')
        );
        $iseed = new Orangehill\Iseed\Iseed();
        $output = $iseed->repackSeedData($data);
        $this->assertEquals(json_encode($data), json_encode($output));
    }

    public function testCanGenerateClassName()
    {
        $iseed = new Orangehill\Iseed\Iseed();<commit_msg>Tests added, code refactored<commit_after><?php

use Mockery as m;
use Illuminate\Database\Schema;

class IseedTest extends PHPUnit_Framework_TestCase {

    protected static $stubsDir, $testStubsDir;

    public function __construct()
    {
        static::$stubsDir = __DIR__.'/../src/Orangehill/Iseed/Stubs';
        static::$testStubsDir = __DIR__.'/Stubs';
    }

    public function tearDown()
    {
        m::close();
    }

    public function testPopulatesStub()
    {
        $productionStub = file_get_contents(static::$stubsDir . '/seed.stub');
        $iseed = new Orangehill\Iseed\Iseed();
        $output = $iseed->populateStub('test_class', $productionStub, 'test_table', 'test_data');
        $expected = file_get_contents(static::$testStubsDir . '/seed.stub');
        $this->assertEquals($expected, $output);
    }

    /**
     * @expectedException Orangehill\Iseed\TableNotFoundException
     * @expectedExceptionMessage Table nonexisting was not found.
     */
    public function testTableNotFoundException()
    {
        $hasTable = m::mock('Orangehill\Iseed\Iseed[hasTable]')->makePartial();
        $hasTable->shouldReceive('hasTable')->once()->andReturn(false);
        $hasTable->generateSeed('nonexisting');
    }

    public function testRepacksSeedData()
    {
        $data = array(
            array('id' => '1', 'name' => 'one'),
            array('id' => '2', 'name' => 'two')
        );
        $iseed = new Orangehill\Iseed\Iseed();
        $output = $iseed->repackSeedData($data);
        $this->assertEquals(json_encode($data), json_encode($output));
    }

    public function testCanGenerateClassName()
    {
        $iseed = new Orangehill\Iseed\Iseed();
{'fraction_non_alphanumeric': 0.14824717765894235, 'fraction_numerical': 0.0011883541295306002, 'mean_word_length': 3.0035671819262784, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, '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': '5175062', 'n_tokens_mistral': 1022, 'n_tokens_neox': 1029, 'n_words': 174}