<commit_before><?php

class WineModelTest extends \LazyRecord\ModelTestCase
{
    public $driver = 'sqlite';

    public function getModels()
    {
        return array(
            'tests\\Wine',
            'tests\\WineCategory',
        );
    }

    public function testWineRecordCreate()
    {
        $record = new \tests\Wine;
        ok($record);
        $ret = $record->create(array( 'name' => 'Wine Name' ));
        result_ok($ret);
    }

    public function testWineCategoryAndRefer()
    {
        $c = new \tests\WineCategory;
        ok($c,'category');

        $record = new \tests\Wine;
        ok($record);

        $ret = $c->create(array( 'name' => 'Wine Category' ));
        result_ok($ret);

        $ret = $record->create(array( 'name' => 'Wine Name' , 'category_id' => $c->id ));
        result_ok($ret);

        ok($record->category->id, 'the belongsTo should be generated from refer attribute');
        ok($record->category_id,'the original column');

        is('Wine Category',$record->display('category'));
    }


    public function testJoinedColumnExtraction() {
        $c = new \tests\WineCategory;
        ok($c,'category');

        $record = new \tests\Wine;
        ok($record);

        $ret = $c->create(array( 'name' => 'Wine Category' ));
        result_ok($ret);

        foreach(  range(1,200) as $i ) {
            $ret = $record->create(array( 'name' => "Wine Name $i" , 'category_id' => $c->id ));
            result_ok($ret);
        }


        ok( $collection = new \tests\WineCollection );
        $collection->join( new \tests\WineCategory ); // join the WineCategory

        // test query
        foreach( $collection as $item ) {
            ok($item->id);

            $data = $item->getData();
            // print_r($data);
            ok( isset($data['category']) );

            $category = $data['category'];
            ok($category->id);


            ok($item->category,'get category object');
            ok($item->category->id, 'get category id');
            ok($item->category->name, 'get category name');

            same_ok($item->category, $category );
        }

    }



}
<commit_msg>runIteration method out<commit_after><?php

class WineModelTest extends \LazyRecord\ModelTestCase
{
    public $driver = 'sqlite';

    public function getModels()
    {
        return array(
            'tests\\Wine',
            'tests\\WineCategory',
        );
    }

    public function testWineRecordCreate()
    {
        $record = new \tests\Wine;
        ok($record);
        $ret = $record->create(array( 'name' => 'Wine Name' ));
        result_ok($ret);
    }

    public function testWineCategoryAndRefer()
    {
        $c = new \tests\WineCategory;
        ok($c,'category');

        $record = new \tests\Wine;
        ok($record);

        $ret = $c->create(array( 'name' => 'Wine Category' ));
        result_ok($ret);

        $ret = $record->create(array( 'name' => 'Wine Name' , 'category_id' => $c->id ));
        result_ok($ret);

        ok($record->category->id, 'the belongsTo should be generated from refer attribute');
        ok($record->category_id,'the original column');

        is('Wine Category',$record->display('category'));
    }


    public function testJoinedColumnExtractionFromCollection() {
        $c = new \tests\WineCategory;
        ok($c,'category');

        $record = new \tests\Wine;
        ok($record);

        $ret = $c->create(array( 'name' => 'Wine Category' ));
        result_ok($ret);

        foreach(  range(1,200) as $i ) {
            $ret = $record->create(array( 'name' => "Wine Name $i" , 'category_id' => $c->id ));
            result_ok($ret);
        }


        ok( $collection = new \tests\WineCollection );
        $collection->join( new \tests\WineCategory ); // join the WineCategory


        // test query
        foreach( $collection as $item ) {
            ok($item->id);
            $data = $item->getData();
            // print_r($data);
            ok( isset($data['category']) );
            $category = $data['category'];
            ok($category->id);
            ok($item->category,'get category object');
            ok($item->category->id, 'get category id');
            ok($item->category->name, 'get category name');
            same_ok($item->category, $category );
        }
        $this->runIteration($collection);
    }


    public function runIteration($collection) {
        foreach( $collection as $item ) {
            ok($item->category->name, 'get category name');
        }
    }


}

{'fraction_non_alphanumeric': 0.1644707949055775, 'fraction_numerical': 0.001756697408871322, 'mean_word_length': 2.0427521710086842, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 62, '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': '1551879', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1336, 'n_words': 284}