#1452: Relations should be automatically loaded when using findById()
-------------------------+--------------------------------------------------
  Reporter:  lsolesen    |       Owner:  jwage                
      Type:  defect      |      Status:  new                  
  Priority:  minor       |   Milestone:  1.0.2                
 Component:  Attributes  |     Version:  1.0                  
Resolution:              |    Keywords:                       
  Has_test:  1           |    Mystatus:  Pending Core Response
 Has_patch:  0           |  
-------------------------+--------------------------------------------------
Comment (by lsolesen):

 /**
  * Doctrine_Ticket_1452_TestCase
  *
  * @package     Doctrine
  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
  * @category    Object Relational Mapping
  * @link        www.phpdoctrine.org
  * @since       1.0
  * @version     $Revision$
  */
 class Doctrine_Ticket_1452_TestCase extends Doctrine_UnitTestCase
 {

     public function prepareTables()
     {
         $this->tables[] = 'Model_Product';
         parent::prepareTables();
     }

     public function
 testFindByIdAutomaticallyLoadsRelationsForInstanceTranslation()
     {
         $name = 'New York';
         $description = 'En dansk beskrivelse';

         try {

             $item = new Model_Product;
             $item->name = $name;
             $item->Translation['DK']->description = $description;
             $item->Translation['EN']->description = 'Some english
 description';
             $item->save();

             $reopened =
 Doctrine::getTable('Model_Product')->findById($item->id);
             $this->assertEqual($name, $reopened->name);
             $this->assertEqual($description,
 $reopened->Translation['DK']->description);

             $this->pass();
         } catch (Exception $e) {
             $this->fail($e->getMessage());
         }
     }
 }

 class Model_Product extends Doctrine_Record
 {
     public function setTableDefinition ()
     {
         $this->hasColumn('name', 'string', 30);
         $this->hasColumn('description', 'string', 65555);
         $this->hasColumn('price', 'integer', 20);
     }
     public function setUp ()
     {
         $this->actAs('I18n', array('fields' => array('description')));
     }
 }

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1452#comment:1>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to