Changeset 4347

Show
Ignore:
Timestamp:
05/10/08 01:03:59 (14 months ago)
Author:
jwage
Message:

fixes #936 - Fixes issue with nested behaviors

Location:
branches/0.11
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Record/Generator.php

    r4322 r4347  
    113113     * @return void 
    114114     */ 
    115     public function addChild(Doctrine_Record_Generator $generator) 
     115    public function addChild($generator) 
    116116    { 
    117117        $this->_options['children'][] = $generator; 
     
    228228 
    229229        foreach ($this->_options['children'] as $child) { 
    230             $this->_table->addGenerator($child, get_class($child)); 
    231  
    232             $child->setTable($this->_table); 
    233  
    234             $child->setUp(); 
     230            if ($child instanceof Doctrine_Template) { 
     231                if ($child->getPlugin() !== null) { 
     232                    $this->_table->addGenerator($child->getPlugin(), get_class($child->getPlugin())); 
     233                } 
     234 
     235                $child->setTable($this->_table); 
     236                $child->setTableDefinition(); 
     237                $child->setUp(); 
     238            } else { 
     239                $this->_table->addGenerator($child, get_class($child)); 
     240                $child->initialize($this->_table); 
     241            } 
    235242        } 
    236243    } 
  • branches/0.11/tests/PluginTestCase.php

    r4029 r4347  
    4242    public function testNestedPluginsGetExportedRecursively() 
    4343    { 
    44  
    45  
    4644        $sql = $this->conn->export->exportClassesSql(array('Wiki')); 
    4745 
    48         $this->assertEqual($sql[0], 'CREATE TABLE wiki_translation_version (title VARCHAR(255), content VARCHAR(2147483647), lang CHAR(2), id INTEGER, version INTEGER, PRIMARY KEY(lang, id, version))'); 
    49         $this->assertEqual($sql[1], 'CREATE TABLE wiki_translation_index (keyword VARCHAR(200), field VARCHAR(50), position INTEGER, lang CHAR(2), id INTEGER, PRIMARY KEY(keyword, field, position, lang, id))'); 
    50         $this->assertEqual($sql[2], 'CREATE TABLE wiki_translation (title VARCHAR(255), content VARCHAR(2147483647), lang CHAR(2), id INTEGER, version INTEGER, PRIMARY KEY(lang, id))'); 
     46        $this->assertEqual($sql[0], 'CREATE TABLE wiki_translation_version (id INTEGER, lang CHAR(2), title VARCHAR(255), content VARCHAR(2147483647), version INTEGER, PRIMARY KEY(id, lang, version))'); 
     47        $this->assertEqual($sql[1], 'CREATE TABLE wiki_translation_index (id INTEGER, lang CHAR(2), keyword VARCHAR(200), field VARCHAR(50), position INTEGER, PRIMARY KEY(id, lang, keyword, field, position))'); 
     48        $this->assertEqual($sql[2], 'CREATE TABLE wiki_translation (id INTEGER, title VARCHAR(255), content VARCHAR(2147483647), lang CHAR(2), version INTEGER, slug VARCHAR(255), PRIMARY KEY(id, lang))'); 
    5149        $this->assertEqual($sql[3], 'CREATE TABLE wiki (id INTEGER PRIMARY KEY AUTOINCREMENT, created_at DATETIME, updated_at DATETIME)'); 
    5250 
     
    8684        $this->assertEqual($wiki->Translation['FI']->version, 2); 
    8785    } 
     86 
     87    public function testSearchableChildTemplate() 
     88    { 
     89          $this->conn->clear(); 
     90 
     91        $wiki = new Wiki(); 
     92        $wiki->state(Doctrine_Record::STATE_TDIRTY); 
     93        $wiki->save(); 
     94        $fi = $wiki->Translation['FI']; 
     95        $fi->title = 'New Title'; 
     96        $fi->content = "Sorry, I'm not able to write a Finish sentence about Michael Jordan..."; 
     97 
     98        $fi->save(); 
     99 
     100        $t = Doctrine::getTable('WikiTranslationIndex'); 
     101        $oQuery = new Doctrine_Search_Query($t); 
     102        $oQuery->query("jordan"); 
     103        $out = $this->conn->fetchAll($oQuery->getSql(), $oQuery->getParams()); 
     104 
     105        $this->assertEqual($out[0]['relevance'], 2); 
     106        $this->assertEqual($out[1]['relevance'], 1); 
     107        $this->assertEqual($out[0]['id'], 1); 
     108        $this->assertEqual($out[1]['id'], 2); 
     109    } 
     110 
     111    public function testSluggableChildTemplate() 
     112    { 
     113          $this->conn->clear(); 
     114 
     115        $wiki = new Wiki(); 
     116        $wiki->state(Doctrine_Record::STATE_TDIRTY); 
     117        $wiki->save(); 
     118        $fi = $wiki->Translation['FI']; 
     119        $fi->title = 'This is the title'; 
     120        $fi->content = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla sed."; 
     121 
     122        $fi->save(); 
     123        $this->assertEqual($fi->slug, 'this-is-the-title'); 
     124                } 
    88125} 
    89126 
     
    98135    public function setUp() 
    99136    { 
    100         $options = array('fields' => array('title', 'content')); 
     137        $options = array('fields' => array('title', 'content')); 
    101138        $auditLog = new Doctrine_Template_Versionable($options); 
    102139        $search = new Doctrine_Template_Searchable($options); 
    103         $slug = new Doctrine_Template_Sluggable($options); 
     140        $slug = new Doctrine_Template_Sluggable(array('fields' => array('title'))); 
    104141        $i18n = new Doctrine_Template_I18n($options); 
    105142 
  • branches/0.11/tests/run.php

    r4336 r4347  
    196196// Behaviors Testing 
    197197$behaviors = new GroupTest('Behaviors Tests', 'behaviors'); 
    198 //$behaviors->addTestCase(new Doctrine_Plugin_TestCase()); 
     198$behaviors->addTestCase(new Doctrine_Plugin_TestCase()); 
    199199$behaviors->addTestCase(new Doctrine_View_TestCase()); 
    200200$behaviors->addTestCase(new Doctrine_AuditLog_TestCase());