public function testI18nExport()
 {
     try {
         $i = new I18nTestExport();
         $i->Translation['en']->title = 'english test';
         $i->Translation['fr']->title = 'french test';
         $i->test_object = new stdClass();
         $i->save();
         $data = new Doctrine_Data();
         $data->exportData('test.yml', 'yml', array('I18nTestExport', 'I18nTestExportTranslation'));
         $array = Doctrine_Parser::load('test.yml', 'yml');
         $this->assertTrue(!empty($array));
         $this->assertTrue(isset($array['I18nTestExport']['I18nTestExport_1']));
         $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_en']));
         $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_fr']));
         $i->Translation->delete();
         $i->delete();
         Doctrine_Core::loadData('test.yml');
         $q = Doctrine_Query::create()->from('I18nTestExport e')->leftJoin('e.Translation t');
         $results = $q->execute();
         $this->assertEqual(get_class($results[0]->test_object), 'stdClass');
         $this->pass();
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
     if (file_exists('test.yml')) {
         unlink('test.yml');
     }
 }
    public function testI18nExport()
    {
        try {
            $i = new I18nTestExport();
            $i->Translation['en']->title = 'english test';
            $i->Translation['fr']->title = 'french test';
            $i->save();
            $i->free();

            $data = new Doctrine_Data();
            $data->exportData('test.yml', 'yml', array('I18nTestExport', 'I18nTestExportTranslation'));

            $array = Doctrine_Parser::load('test.yml', 'yml');

            $this->assertTrue( ! empty($array));
            $this->assertTrue(isset($array['I18nTestExport']['I18nTestExport_1']));
            $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_en']));
            $this->assertTrue(isset($array['I18nTestExportTranslation']['I18nTestExportTranslation_1_fr']));

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

        if (file_exists('test.yml')) {
            unlink('test.yml');
        }
    }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($options['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $dir = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'fixtures';
     $excludedModels = array('Modification', 'ModificationField');
     Doctrine::loadModels(sfConfig::get('sf_lib_dir') . DIRECTORY_SEPARATOR . 'model' . DIRECTORY_SEPARATOR . 'doctrine');
     $loadedModels = Doctrine::getLoadedModels();
     $models = array_diff($loadedModels, $excludedModels);
     $data = new Doctrine_Data();
     $data->exportData($dir, 'yml', $models, false);
 }
Example #4
0
 /**
  * Load data from a yaml fixtures file.
  * The output of dumpData can be fed to loadData
  *
  * @param string $yamlPath Path to your yaml data fixtures
  * @param string $append Whether or not to append the data
  * @return void
  */
 public static function loadData($yamlPath, $append = false)
 {
     $data = new Doctrine_Data();
     return $data->importData($yamlPath, 'yml', array(), $append);
 }
Example #5
0
 /**
  * Load data from a yaml fixtures file.
  * The output of dumpData can be fed to loadData
  *
  * @param string $yamlPath Path to your yaml data fixtures
  * @param string $append Whether or not to append the data
  * @return void
  */
 public static function loadData($yamlPath, $append = false, $charset = 'UTF-8')
 {
     $data = new Doctrine_Data();
     return $data->importData($yamlPath, 'yml', array(), $append, $charset);
 }
Example #6
0
 /**
  * Load data from a yaml fixtures file.
  * The output of dumpData can be fed to loadData
  *
  * @param string $yamlPath Path to your yaml data fixtures
  * @param string $append Whether or not to append the data
  * @return void
  */
 public static function loadData($yamlPath, $append = false)
 {
     $data = new Doctrine_Data();
     if (!$append) {
         $data->purge();
     }
     return $data->importData($yamlPath, 'yml');
 }