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');
     }
 }
 /**
  * Set up the functional test to use a database (doctrine)
  * Loads test Data for functional tests - model database and sets up a dummy user
  *
  * @return object the context
  */
 public function loadData()
 {
     exec(dirname(__FILE__) . '/../../symfony doctrine:build --all --and-load --env=test --no-confirmation');
     exec(dirname(__FILE__) . '/../../symfony guard:create-user apptest abc123 --env=test');
     Doctrine_Core::loadData(sfConfig::get('sf_test_dir') . '/fixtures/50_FunctionalAll/table.yml', true);
     exec(dirname(__FILE__) . '/../../symfony cc --env=test');
     return $this;
 }
    public function testInlineMultiple()
    {
        $yml = <<<END
---
DC147_Multiple:
  ISBN2:
    name: isbn2
  ISBN3:
    name: isbn3
DC147_Product: 
  Product_1: 
    name: book3
    MultipleValues:
      Multi_1:
        value: 123345678
        Multiple: ISBN2
      Multi_2:
        value: 232323233
        Multiple: ISBN3
  Product_2: 
    name: book4
    MultipleValues:
      Multi_3:
        value: 444455555
        Multiple: ISBN2
      Multi_4:
        value: 232323233
        Multiple: ISBN3
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $this->conn->clear();
            $query = new Doctrine_Query();
            $query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book3');
            $product = $query->fetchOne();
            $this->assertEqual($product->name, 'book3');
            $this->assertEqual($product->MultipleValues->count(), 2);
            $this->assertEqual($product->MultipleValues[0]->value, '123345678');
            $this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
            $this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
            $query = new Doctrine_Query();
            $query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book4');
            $product = $query->fetchOne();
            $this->assertEqual($product->name, 'book4');
            $this->assertEqual($product->MultipleValues->count(), 2);
            $this->assertEqual($product->MultipleValues[0]->value, '444455555');
            $this->assertEqual($product->MultipleValues[1]->value, '232323233');
            $this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
            $this->assertEqual(is_object($product->MultipleValues[1]->Multiple), true);
            $this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
            $this->assertEqual($product->MultipleValues[1]->Multiple->name, 'isbn3');
            $this->pass();
        } catch (Exception $e) {
            $this->fail();
        }
        unlink('test.yml');
    }
/**
 * Populate database with YAML fixtures
 * @param string $name
 */
function doctrine_populate_database($name = NULL)
{
    if ($name === NULL) {
        $location = FIXTURES_DIRECTORY;
    } else {
        $location = FIXTURES_DIRECTORY . $name . '.yml';
    }
    Doctrine_Core::loadData($location);
}
    public function testTest()
    {
        $yml = <<<END
---
Ticket_DC23_BlogPost:
  BlogPost_1:
    Translation:
      en:
        title: Test
        body: Testing

Ticket_DC23_User: 
  User_1: 
    name: jwage
    Contact:
      name: Test Contact
      Address: Address_1
      Phonenumbers:
        Phonenumber_1:
          name: test1
        Phonenumber_2:
          name: test2
  User_2:
    name: romanb
    Contact:
      name: Roman
      Address:
        name: Testing
      Phonenumbers: [Phonenumber_3]

Ticket_DC23_Phonenumber:
  Phonenumber_3:
    name: Testing

Ticket_DC23_Address:
  Address_1:
    name: Test Address
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $q = Doctrine_Query::create()->from('Ticket_DC23_User u')->leftJoin('u.Contact c')->leftJoin('c.Phonenumbers p')->leftJoin('c.Address a');
            $results = $q->fetchArray();
            $this->assertTrue(isset($results[0]['Contact']['address_id']));
            $this->assertEqual(count($results[0]['Contact']['Phonenumbers']), 2);
            $this->assertEqual(count($results[1]['Contact']['Phonenumbers']), 1);
            $q = Doctrine_Query::create()->from('Ticket_DC23_BlogPost p')->leftJoin('p.Translation t');
            $results = $q->fetchArray();
            $this->assertEqual(count($results[0]['Translation']), 1);
            $this->pass();
        } catch (Exception $e) {
            echo $e->getTraceAsString();
            $this->fail($e->getMessage());
        }
        unlink('test.yml');
    }
 /**
  * Проверим что полученный yaml загружается в БД
  * @see Doctrine_Core::loadData()
  */
 public function testLoadData()
 {
     $csvImport = new myImportCsvVkoshelke($this->_csvData);
     $success = $csvImport->execute($this->_user);
     $this->assertTrue($success, 'Импорт должен завершиться успешно');
     file_put_contents($this->_ymlFileName, $csvImport->getYmlData());
     Doctrine_Core::loadData($this->_ymlFileName, true);
     $transfer = Doctrine::getTable('Operation')->findOneByTransferAmount('300000.00', Doctrine::HYDRATE_ARRAY);
     $this->assertNotEmpty($transfer, 'Перевод должен попасть в БД');
     $this->assertEquals(Operation::TYPE_TRANSFER, $transfer['type'], 'Тип операции перевода должен быть ' . Operation::TYPE_TRANSFER);
     $this->assertEquals('2010-06-06', $transfer['date'], 'Дата операции должна совпадать с датой в CSV');
 }
    public function testTest()
    {
        $yml = <<<END
Ticket_1351_Article:
  Ticket_1351_Article_1:
    Translation:
      en:
        title: Test title english
        body: Test body english
      fr:
        title: Test title french
        body: Test body french
END;
        file_put_contents('test.yml', $yml);
        Doctrine_Core::loadData('test.yml', true);
        unlink('test.yml');
        $results = Doctrine_Query::create()->from('Ticket_1351_Article a, a.Translation t')->fetchArray();
        $this->assertEqual($results[0]['Translation']['en']['title'], 'Test title english');
    }
<?php

// test/unit/model/doctrine/RepositoryTableTest.php
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
// test環境でDB初期化
$configuration = ProjectConfiguration::getApplicationConfiguration('taskapp', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(dirname(__FILE__) . '/RepositoryFixture.yml');
$t = new lime_test(4);
// getInstance
$t->ok(($table = RepositoryTable::getInstance()) instanceof RepositoryTable, 'RepositoryTableインスタンス取得');
// レコード取得
$t->diag('findAll()');
$list = $table->findAll();
$t->is(count($list), 2, 'レコード全件取得');
// レコード取得
$t->diag('findOne***()');
$commit = $table->findOneByName('testrepo2');
$t->ok($commit instanceof Repository, 'レコードの取得成功');
$t->is($commit->getRepository(), 'git://github.com/hidenorigoto/test2.git', '取得したレコードのデータが正常');
Exemple #9
0
if (array_key_exists(1, $argv)) {
    $env = $argv[1];
} else {
    $env = 'production';
}
defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__) . '/..'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(realpath(BASE_PATH . '/library'), get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$config = array('config' => array(realpath(BASE_PATH . '/configs/application.ini')));
$application = new Zend_Application($env, $config);
$dbConnection = $application->getBootstrap()->bootstrap('Doctrine');
try {
    Doctrine_Core::dropDatabases();
} catch (Doctrine_Connection_Mysql_Exception $e) {
    error_log('The database did not exists');
}
Doctrine_Core::createDatabases();
$options = $application->getOptions();
$ymlPath = realpath(BASE_PATH . '/Scripts/Yaml/Schema/Koryukan.yml');
$modelsOptions = array('suffix' => '.php', 'generateTableClasses' => true, 'classPrefix' => 'Koryukan_Db_', 'classPrefixFiles' => false, 'baseClassPrefix' => 'Base', 'baseClassesDirectory' => '');
Doctrine_Core::generateModelsFromYaml($ymlPath, $options['db']['objectsPath'], $modelsOptions);
Doctrine_Core::createTablesFromModels($options['db']['objectsPath']);
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/news.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/storeItems.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/images.yml');
Doctrine_Core::loadData(BASE_PATH . '/Scripts/Yaml/Data/security.yml');
 * This file is part of the lyMediaManagerPlugin package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * Functional tests for file system errors.
 *
 * @package     lyMediaManagerPlugin
 * @subpackage  functional tests
 * @copyright   Copyright (C) 2010 Massimo Giagnoni.
 * @license     http://www.symfony-project.org/license MIT
 * @version     SVN: $Id$
 */
include dirname(__FILE__) . '/../bootstrap/functional.php';
Doctrine_Core::loadData(dirname(__FILE__) . '/../data/fixtures/fixtures_fs.yml');
$root = Doctrine::getTable('lyMediaFolder')->findOneByName('media');
$subf1 = lyMediaFolderTable::getInstance()->findOneByName('testsub1');
$subf2 = lyMediaFolderTable::getInstance()->findOneByName('testsub2');
//Creates some test assets. Cannot be done in fixtures
$file = dirname(__FILE__) . '/../data/assets/asset1.png';
$asset = new lyMediaAsset();
$asset->setFolder($subf1);
$asset->setFilename($file);
$asset->save();
$asset->refresh();
$file = dirname(__FILE__) . '/../data/assets/asseta.png';
$asset2 = new lyMediaAsset();
$asset2->setFolder($subf2);
$asset2->setFilename($file);
$asset2->save();
<?php

// test/unit/model/doctrine/PageTableTest.php
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
// test環境でDB初期化
$configuration = ProjectConfiguration::getApplicationConfiguration('taskapp', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(dirname(__FILE__) . '/PageFixture.yml');
$t = new lime_test(60);
// getInstance
$t->diag('getInstance()');
$table = PageTable::getInstance();
$t->ok($table instanceof PageTable, 'テーブルインスタンス取得');
// レコード取得
$t->diag('findAll()');
$list = $table->findAll();
$t->is(count($list), 4, 'レコード全件取得');
// レコード取得
$t->diag('findOne***()');
$page = $table->findOneByPath('/foo/bar');
$t->ok($page instanceof Page, 'レコードの取得成功');
$t->is($page->getTitle(), 'testtitle', '取得したレコードのデータが正常');
// getFromPath
$t->diag('getFromPath()');
$page = PageTable::getFromPath('/foo/bar');
$t->is($page->getTitle(), 'testtitle', '取得したレコードのデータが正常');
$t->is($page->getRepository()->getName(), 'testrepo', 'リレーション先も正しく取得');
// getListFromPath()
$t->diag('getListFromPath()');
$page_rec = PageTable::getListFromPath('/foo/');
// 最終更新日時を更新しておく。
 public function up()
 {
     Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/restore.yml', true);
 }
Exemple #13
0
 /**
  * loads the test data. 
  * This is executed only if the user has set this option during installation.
  *
  * @return void
  **/
 private function loadSampleData()
 {
     if (PropertyTable::get('sample_data_load')) {
         Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/fixtures/test', false);
         CommonTable::calculateTotals(true);
         $i18n = $this->getContext()->getI18N();
         $this->getUser()->info($i18n->__("Sample data has been loaded."));
         PropertyTable::set('sample_data_load', 0);
     }
 }
Exemple #14
0
<?php

// test/bootstrap/Doctrine.php
include dirname(__FILE__) . '/unit.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(sfConfig::get('sf_test_dir') . '/fixtures');
    public function testI18nImportWithInteger()
    {
        $yml = <<<END
---
I18nNumberLang:
  I18nNumberLang_1:
    name: test
    Translation:
      0:
        title: english title
        body: english body
      1:
        title: french title
        body: french body
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $this->conn->clear();
            $query = new Doctrine_Query();
            $query->from('I18nNumberLang i, i.Translation t');
            $i = $query->execute()->getFirst();
            $this->assertEqual($i->name, 'test');
            $this->assertEqual($i->Translation['0']->title, 'english title');
            $this->assertEqual($i->Translation['1']->title, 'french title');
            $this->assertEqual($i->Translation['0']->body, 'english body');
            $this->assertEqual($i->Translation['1']->body, 'french body');
            $this->pass();
        } catch (Exception $e) {
            $this->fail($e->getMessage());
        }
        unlink('test.yml');
    }
 public function loadData($append = false)
 {
     $this->_loadDoctrineModels();
     Doctrine_Core::loadData($this->_getDataFixtureDirectoryPath(), $append);
     $this->_print('Successfully loaded data from fixture.', array('color' => 'green'));
 }
Exemple #17
0
 public static function syncdb($apps = null, $drop_database = false, $append = true)
 {
     if (!self::$inited || !self::$connections) {
         self::init();
     }
     if (!$apps) {
         $apps = ini('base/INSTALLED_APPS');
     }
     if (!$apps) {
         return true;
     }
     if ($drop_database) {
         Doctrine_Core::dropDatabases();
         Doctrine_Core::createDatabases();
     }
     foreach ((array) $apps as $k => $app) {
         $app = str_replace('.', '/', $app);
         try {
             /*
              * Generate the models
              */
             if (isset($_GET['use_yaml'])) {
                 $schemas = Package::get_file(sprintf('applications/%s/%s', $app, 'schemas.yml'));
                 if (!is_file($schemas)) {
                     continue;
                 }
                 Doctrine_Core::generateModelsFromYaml($schemas, Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
             } else {
                 try {
                     import(sprintf('applications/%s/models/generated/*', $app));
                 } catch (DoesNotExistsException $e) {
                     continue;
                 }
             }
             /*
              * syncdb
              */
             Doctrine_Core::createTablesFromModels(Package::get_folder(sprintf('applications/%s/models', $app)), self::$_generate_options);
             /*
              * Insert test data
              */
             $dir = Package::get_folder(sprintf('applications/%s/fixtures', $app));
             if (is_dir($dir)) {
                 Doctrine_Core::loadData($dir, $append);
             }
         } catch (PDOException $e) {
             continue;
         }
     }
 }
 function load_data()
 {
     Doctrine_Core::loadData(APPPATH . 'models/fixtures/');
     echo "Data loaded<br />";
 }
Exemple #19
0
<?php

// test/unit/model/doctrine/CommitTest.php
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
// test環境でDB初期化
$configuration = ProjectConfiguration::getApplicationConfiguration('taskapp', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(dirname(__FILE__) . '/CommitFixture.yml');
$t = new lime_test(12);
// construct
$t->diag('__construct()');
$t->ok(new Commit() instanceof Commit, 'Commitインスタンス化');
$page = PageTable::getInstance()->findOneByPath('/foo/bar');
// create
$t->diag('create');
$commit = new Commit();
$commit->setCommittedAt('2010/05/19 01:02:03');
$commit->setAuthorHandle('author_handle');
$commit->setAuthorEmail('author_email');
$commit->setCommitterHandle('committer_handle');
$commit->setCommitterEmail('committer_email');
$commit->setCommitKey('commit_key');
$commit->setPage($page);
$commit->save();
$commit = CommitTable::getInstance()->findOneByCommitKey('commit_key');
$t->ok($commit instanceof Commit, 'レコードが正しく保存された');
$t->is($commit->getDateTimeObject('committed_at')->format('Y/m/d H:i:s'), '2010/05/19 01:02:03', 'コミット日時の保存');
$t->is($commit->getAuthorHandle(), 'author_handle', '作者ハンドルの保存');
$t->is($commit->getAuthorEmail(), 'author_email', '作者メールアドレスの保存');
$t->is($commit->getCommitterHandle(), 'committer_handle', 'コミッターハンドルの保存');
$t->is($commit->getCommitterEmail(), 'committer_email', 'コミッターメールアドレスの保存');
Exemple #20
0
 public function execute()
 {
     Doctrine_Core::loadModels($this->getArgument('models_path'));
     Doctrine_Core::loadData($this->getArgument('data_fixtures_path'), $this->getArgument('append', false));
     $this->notify('Data was successfully loaded');
 }
Exemple #21
0
 /**
  * Create the ShineISP Database
  */
 public static function createDb($installsampledata = true)
 {
     try {
         $dbconfig = Shineisp_Main::databaseConfig();
         $dsn = Shineisp_Main::getDSN();
         $conn = Doctrine_Manager::connection($dsn, 'doctrine');
         $conn->execute('SHOW TABLES');
         # Lazy loading of the connection. If I execute a simple command the connection to the database starts.
         $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
         $conn->setCharset('UTF8');
         $dbh = $conn->getDbh();
         $models = Doctrine::getLoadedModels();
         // Set the current connection
         $manager = Doctrine_Manager::getInstance()->setCurrentConnection('doctrine');
         if ($conn->isConnected()) {
             $migration = new Doctrine_Migration(APPLICATION_PATH . '/configs/migrations');
             // Get the latest version set in the migrations directory
             $latestversion = $migration->getLatestVersion();
             if (empty($latestversion)) {
                 $latestversion = 0;
             }
             // Clean the database
             $conn->execute('SET FOREIGN_KEY_CHECKS = 0');
             foreach ($models as $model) {
                 $tablename = Doctrine::getTable($model)->getTableName();
                 $dbh->query("DROP TABLE IF EXISTS {$tablename}");
             }
             // Create the migration_version table
             Doctrine_Manager::getInstance()->getCurrentConnection()->execute('DROP TABLE IF EXISTS `migration_version`;CREATE TABLE `migration_version` (`version` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1;INSERT INTO `migration_version` VALUES (' . $latestversion . ')');
             // Create all the tables in the database
             Doctrine_Core::createTablesFromModels(APPLICATION_PATH . '/models');
             // Common resources
             Doctrine_Core::loadData(APPLICATION_PATH . '/configs/data/fixtures/commons/', true);
             // Sample data
             if ($installsampledata) {
                 $import = new Doctrine_Data_Import(APPLICATION_PATH . '/configs/data/fixtures/');
                 $import->setFormat('yml');
                 $import->setModels($models);
                 $import->doImport(true);
             }
             $conn->execute('SET FOREIGN_KEY_CHECKS = 1');
             // Update the version in the config.xml file previously created
             Settings::saveConfig($dbconfig, $latestversion);
         } else {
             echo "No Connection found";
         }
     } catch (Exception $e) {
         die($e);
     }
     // return the latest version
     return $latestversion;
 }
 /**
  * @return snTestFunctional
  */
 public function loadData()
 {
     Doctrine_Core::loadData(sfConfig::get('sf_data_dir') . '/fixtures');
     return $this;
 }
<?php

/**
 * timpanyCart tests.
 */
include dirname(__FILE__) . '/../../../../../test/bootstrap/unit.php';
$t = new lime_test(24);
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
new sfDatabaseManager($configuration);
Doctrine_Core::loadData(dirname(__FILE__) . '/../../fixtures');
$_SERVER['session_id'] = 'test_guest';
$guestDispatcher = new sfEventDispatcher();
$guestSessionPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'symfony_tests_' . rand(1, 999);
$guestStorage = new sfSessionTestStorage(array('session_path' => $guestSessionPath));
$guestUser = new myUser($guestDispatcher, $guestStorage);
$product_1 = timpanyProductTable::getInstance()->findOneById(1);
$product_2 = timpanyProductTable::getInstance()->findOneById(2);
$guestCart = timpanyCart::getInstance($guestUser);
$t->is($guestCart->isEmpty(), true, 'cart is empty');
$t->comment('Put one item into cart.');
$guestCart->addProduct($product_1);
$t->is($guestCart->isEmpty(), false, 'cart is not empty');
$t->is($guestCart->getItemCount(), 1, '1 item in cart');
$t->is($guestCart->getProductCount(), 1, '1 product in cart');
$t->is($guestCart->getNetSum(), 0.84, 'cart net sum is correct');
$t->is($guestCart->getGrossSum('de'), 0.9, 'cart gross sum is correct');
$t->comment('Put second item into cart.');
$guestCart->addProduct($product_2);
$t->is($guestCart->isEmpty(), false, 'cart is not empty');
$t->is($guestCart->getItemCount(), 2, '2 items in cart');
$t->is($guestCart->getProductCount(), 2, '2 products in cart');
 /** Loads and evaluates a fixture file.
  *
  * @param string $file Absolute path to the file.
  *
  * @return void
  */
 protected function _loadFile($file)
 {
     Doctrine_Core::loadData($file, true);
 }
    $i1 = new rtShopStock();
    $i1->save();
    $t->pass('->save() rtShopStock allows empty saves');
    $i1->delete();
} catch (Exception $e) {
    $t->fail('->save() throws an Exception!');
}
// Clean up
unset($i1);
// Fixtures path
$fixtures_path = sfConfig::get('sf_plugins_dir') . '/rtShopPlugin/test/fixtures';
// Check that fixtures direcory abvailable
if (is_dir($fixtures_path)) {
    try {
        rtShopStockTestTools::clean();
        Doctrine_Core::loadData($fixtures_path);
        $t->pass('->loadData() of fixtures worked');
    } catch (Exception $e) {
        var_dump($e->getMessage());
        $t->fail('->loadData() of fixtures failed!');
    }
    $t->diag('-----------------------------------------------------------------------------');
    $t->diag('2. Add product promotion data');
    $t->diag('-----------------------------------------------------------------------------');
    // Add promotions data
    $data = new rtShopStockTestTools();
    // No date restriction - valid
    $product_id = 1;
    $promo1 = $data->createProductPromotion($product_id, '%10 off product');
    $p1 = Doctrine::getTable('rtShopPromotionProduct')->find($promo1);
    $t->isa_ok($p1, 'rtShopPromotionProduct', '::find() created and retrieved product promotion with Id ' . $promo1);
    public function testImport()
    {
        $yml = <<<END
Director:
  david_nutter:
    name: David Nutter


Writer:
  alfred_gough:
    name: Alfred Gough
  miles_millar:
    name: Miles Millar


News:
  News_1:
    title: Date de retour de Smallville aux Etats-Unis

  News_2:
    title: Audiences de l'épisode 8.22 Doomsday aux Etats-Unis


Episode:
  Episode_101:
    season: 1
    number: 1
    title_us: Pilot
    title_fr: Bienvenue sur Terre
    Directors: [david_nutter]
    Writers: [alfred_gough, miles_millar]
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $this->conn->clear();
            $query = new Doctrine_Query();
            $query->from('Episode e, e.Directors, e.Writers');
            $e = $query->execute();
            $this->assertEqual($e->count(), 1);
            $this->assertEqual($e[0]->season, 1);
            $this->assertEqual($e[0]->number, 1);
            $this->assertEqual($e[0]->title_us, 'Pilot');
            $this->assertEqual($e[0]->title_fr, 'Bienvenue sur Terre');
            $this->assertEqual($e[0]->Directors->count(), 1);
            $this->assertEqual($e[0]->Directors[0]->name, 'David Nutter');
            $this->assertEqual($e[0]->Writers->count(), 2);
            $this->assertEqual($e[0]->Writers[0]->name, 'Alfred Gough');
            $this->assertEqual($e[0]->Writers[1]->name, 'Miles Millar');
            $query = new Doctrine_Query();
            $query->from('News n');
            $n = $query->execute();
            $this->assertEqual($n->count(), 2);
            $this->assertEqual($n[0]->title, 'Date de retour de Smallville aux Etats-Unis');
            $this->assertEqual($n[1]->title, 'Audiences de l\'épisode 8.22 Doomsday aux Etats-Unis');
            $this->pass();
        } catch (Exception $e) {
            $this->fail();
        }
        unlink('test.yml');
    }
Exemple #27
0
 public function executeInitTestDatabase(sfWebRequest $request)
 {
     $this->forward404if(!$request->getParameter('just_for_test'));
     Doctrine_Core::loadData(dirname(__FILE__) . '/../../../../../data/fixtures/test/fixtures.yml');
     return sfView::NONE;
 }