Changeset 4379

Show
Ignore:
Timestamp:
05/19/08 16:39:04 (14 months ago)
Author:
jwage
Message:

fixes #1051

Location:
branches/0.11
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Data/Import.php

    r4346 r4379  
    199199            } else if ($obj->getTable()->hasRelation($key)) { 
    200200                if (is_array($value)) { 
    201                     if (isset($value[0])) { 
     201                    if (isset($value[0]) && ! is_array($value[0])) { 
    202202                        foreach ($value as $link) { 
    203203                            if ($obj->getTable()->getRelation($key)->getType() === Doctrine_Relation::ONE) { 
  • branches/0.11/tests/Data/ImportTestCase.php

    r4297 r4379  
    4040        $this->tables[] = 'I18nTest'; 
    4141        $this->tables[] = 'ImportNestedSet'; 
     42        $this->tables[] = 'I18nNumberLang'; 
    4243        parent::prepareTables(); 
    4344    } 
     
    434435        unlink('test.yml'); 
    435436    } 
     437 
     438    public function testI18nImportWithInteger() 
     439    { 
     440        $yml = <<<END 
     441--- 
     442I18nNumberLang: 
     443  I18nNumberLang_1: 
     444    name: test 
     445    Translation: 
     446      0: 
     447        title: english title 
     448        body: english body 
     449      1: 
     450        title: french title 
     451        body: french body 
     452END; 
     453        try { 
     454            file_put_contents('test.yml', $yml); 
     455            Doctrine::loadData('test.yml'); 
     456 
     457            $this->conn->clear(); 
     458 
     459            $query = new Doctrine_Query(); 
     460            $query->from('I18nNumberLang i, i.Translation t'); 
     461 
     462            $i = $query->execute()->getFirst(); 
     463 
     464            $this->assertEqual($i->name, 'test'); 
     465            $this->assertEqual($i->Translation['0']->title, 'english title'); 
     466            $this->assertEqual($i->Translation['1']->title, 'french title'); 
     467            $this->assertEqual($i->Translation['0']->body, 'english body'); 
     468            $this->assertEqual($i->Translation['1']->body, 'french body'); 
     469 
     470            $this->pass(); 
     471        } catch (Exception $e) { 
     472            $this->fail($e->getMessage()); 
     473        } 
     474 
     475        unlink('test.yml');  
     476    } 
     477 
    436478} 
    437479 
     
    448490    } 
    449491} 
     492 
     493class I18nNumberLang extends Doctrine_Record 
     494{ 
     495    public function setTableDefinition() 
     496    { 
     497        $this->hasColumn('name', 'string', 255); 
     498        $this->hasColumn('title', 'string', 255); 
     499        $this->hasColumn('body', 'clob'); 
     500    } 
     501 
     502    public function setUp() 
     503    { 
     504        $this->actAs('I18n', array('fields' => array('title', 'body'), 'type' => 'integer', 'length' => 4)); 
     505    } 
     506}