public function setup() { $db = $this->databasemanager->getDatabase('doctrine'); /* @var $db sfDoctrineDatabase */ // Special Handling for postgre, since droping even when closing the connection, fails with // SQLSTATE[55006]: Object in use: 7 ERROR: database "cs_doctrine_act_as_sortable_test" is being accessed by other users DETAIL: There are 1 other session(s) using the database. if ($db->getDoctrineConnection() instanceof Doctrine_Connection_Pgsql) { try { $db->getDoctrineConnection()->createDatabase(); } catch (Exception $e) { } $export = new Doctrine_Export_Pgsql($db->getDoctrineConnection()); $import = new Doctrine_Import_Pgsql($db->getDoctrineConnection()); $tablenames = array(SortableArticleTable::getInstance()->getTableName(), SortableArticleUniqueByTable::getInstance()->getTableName(), SortableArticleCategoryTable::getInstance()->getTableName()); foreach ($tablenames as $tablename) { if ($import->tableExists($tablename)) { $export->dropTable($tablename); } } } else { try { // ignore error if database does not yet exist (clean CI-env) $db->getDoctrineConnection()->dropDatabase(); } catch (Exception $e) { } $db->getDoctrineConnection()->createDatabase(); } // Using Doctrine instead of Doctrine_Core keeps it symfony 1.2 compatible, which uses Doctrine::loadModels(dirname(__FILE__) . '/../fixtures/project/lib/model/doctrine', Doctrine::MODEL_LOADING_CONSERVATIVE); Doctrine::createTablesFromArray(Doctrine::getLoadedModels()); Doctrine::loadData(dirname(__FILE__) . '/../fixtures/project/data/fixtures/categories.yml'); }
public function loadData($configuration) { new sfDatabaseManager($configuration); self::initiateDB($configuration); Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures'); return $this; }
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::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'); } }
/** * DOCUMENT ME * @param mixed $path * @return mixed */ public function loadData($path = null) { if (!$path) { $path = sfConfig::get('sf_test_dir') . '/fixtures'; } Doctrine::loadData($path); return $this; }
public function run() { $path = $this->options['dir'] . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . $this->options['name'] . '.yml'; if (!file_exists($path)) { throw new RuntimeException('The specified yml doesn\'t exist.'); } Doctrine::loadData($path, true); }
public function loadData($file = null) { $fixture = sfConfig::get('sf_test_dir') . '/fixtures'; if ($file !== null) { $fixture .= "/{$file}"; } Doctrine::loadData($fixture); }
public function setUp() { parent::resetMongo(); sfConfig::set('sf_environment', 'test'); Doctrine::loadData(dirname(__FILE__) . '/fixtures'); sfConfig::set('sf_environment', 'dev'); $this->from = date('Y-m-d', strtotime("today")); $this->to = date('Y-m-d', strtotime("tomorrow")); }
public function testUpdateOwnedIdentities() { parent::resetMongo(); Doctrine::loadData(dirname(__FILE__) . '/fixtures'); $lUserHugo = UserTable::getByIdentifier('hugo'); $lUserHugo->updateOwnedIdentities(array("1", "2", "34")); $lRelation = $lUserHugo->retrieveUserRelations(); $this->assertTrue(in_array("34", $lRelation->getOwnedOi())); }
function load_fixtures() { echo 'This will delete all existing data!<br /> <form action="" method="POST"> <input type="submit" name="action" value="Load Fixtures"><br /><br />'; if ($this->input->post('action')) { Doctrine_Manager::connection()->execute('SET FOREIGN_KEY_CHECKS = 0'); Doctrine::loadData(APPPATH . '/fixtures'); echo "Done!"; } }
public function loadData($file = null) { if ($this->connection == null) { $this->connection = Doctrine_Manager::connection(); $this->connection->beginTransaction(); } $fixture = sfConfig::get('sf_test_dir') . '/fixtures'; if ($file !== null) { $fixture .= "/{$file}"; } Doctrine::loadData($fixture); }
public function setUp() { $manager = Doctrine_Manager::getInstance(); foreach ($manager as $conn) { $modelsPath = APPLICATION_PATH . '/models'; $fixturesPath = APPLICATION_PATH . '/../doctrine/data/fixtures'; $name = array($conn->getName()); Doctrine::dropDatabases($name); Doctrine::createDatabases($name); Doctrine::createTablesFromModels($modelsPath); Doctrine::loadData($fixturesPath, true); } }
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::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'); }
public function setUp() { //parent::resetMongo(); sfConfig::set('sf_environment', 'test'); Doctrine::loadData(dirname(__FILE__) . '/fixtures'); sfConfig::set('sf_environment', 'dev'); $this->table = Doctrine::getTable('Deal'); $this->deal1 = $this->table->findOneBy('name', 'Campaign No. 1'); $this->deal2 = $this->table->findOneBy('name', 'Campaign No. 2'); $this->deal3 = $this->table->findOneBy('name', 'Campaign No. 3'); $this->deal4 = $this->table->findOneBy('name', 'Campaign No. 4'); $this->deal5 = $this->table->findOneBy('name', 'Campaign No. 5'); $this->deal6 = $this->table->findOneBy('name', 'Campaign No. 6'); $this->deal7 = $this->table->findOneBy('name', 'Campaign No. 7'); $this->dealCommission1 = $this->table->findOneBy('name', 'Campaign No. Commission 1'); $this->dealCommission2 = $this->table->findOneBy('name', 'Campaign No. Commission 2'); $this->dealCommission3 = $this->table->findOneBy('name', 'Campaign No. Commission 3'); $this->hugo = UserTable::getInstance()->findOneByUsername('hugo'); $this->affe = UserTable::getInstance()->findOneByUsername('affe'); }
function action_load_fixtures() { ?> This will delete all existing data!<br /> <form action="" method="POST"> <input type="submit" name="schema" value="Load Schema"><br /><br /> <?php ?> This will delete all existing data!<br /> <form action="" method="POST"> <input type="submit" name="data" value="Load Fixtures"><br /><br /> <?php if (!empty($_POST['schema'])) { Doctrine_Core::generateModelsFromYaml(APPPATH . DIRECTORY_SEPARATOR . 'doctrine/fixtures/schema', APPPATH . DIRECTORY_SEPARATOR . 'doctrine/models', array('generateBaseClasses' => false)); echo "Done!"; } elseif (!empty($_POST['data'])) { Doctrine_Manager::connection()->execute("\r\n\t\t\t\tSET FOREIGN_KEY_CHECKS = 0\r\n\t\t\t"); Doctrine::loadData(APPPATH . DIRECTORY_SEPARATOR . 'doctrine/fixtures/data'); echo "Done!"; } }
public function setUp() { try { //Load path configs $root_path = str_replace('test', '', dirname(__FILE__)); $docCfg = Zend_Registry::get('config')->doctrine->toArray(); foreach ($docCfg as &$cfg) { $cfg = str_replace("{ROOT_PATH}", $root_path, $cfg); } //Generate Database structure for tests $this->tearDown(); Doctrine::createDatabases(); Doctrine::createTablesFromModels($docCfg['models_path']); Doctrine::loadModel($docCfg['models_path']); Doctrine::loadData($docCfg['data_fixtures_path']); Util_Log::get()->UnitTests()->debug('Executed Env SetUp'); } catch (Exception $e) { Util_Log::get()->UnitTests()->debug('Failed Setting up environment'); Util_Log::get()->UnitTests()->err($e->getMessage()); } }
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; Doctrine::loadData(sfConfig::get('sf_data_dir') . '/fixtures'); $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('doctrine', 'sfTesterDoctrine'); $browser->call('usermodel/1/concept/200.html', 'put', array('bloom_evaluation' => 0, 'concept_id' => 200, '_with_csrf' => true))->with('doctrine')->begin()->check('UserModel', array('bloom_evaluation' => 0, 'concept_id' => 200))->end();
<?php include dirname(__FILE__) . '/../bootstrap/doctrine.php'; // Initialize the test object $t = new lime_test(11, new lime_output_color()); $playlist_files_table = Doctrine_Core::getTable('PlaylistFiles'); //add the required fixtures Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures/00_PlaylistFilesTable'); $t->comment('->addPlaylistFile()'); $result = $playlist_files_table->addPlaylistFiles(1, '9ewf9ewjfa0jew90fejf9fje', 'song'); $t->is($result, true, 'added a new song to the default playlist'); $result2 = $playlist_files_table->addPlaylistFiles(1, 2, 'album'); $t->is($result2, true, 'added a new album to the default playlist'); $result3 = $playlist_files_table->addPlaylistFiles(1, 1, 'artist'); $t->is($result3, true, 'added a new artist to the default playlist'); $t->comment('->addFiles()'); $result = $playlist_files_table->addFiles(1, array()); $t->is($result, false, 'Array with no items is rejected'); $result = $playlist_files_table->addFiles(1, ''); $t->is($result, false, 'String is rejected'); $result = $playlist_files_table->addFiles(1, array(array('filename' => 'file://localhost/home/music/song.mp3'), array('filename' => 'file://localhost/home/music/song3.mp3'))); $t->is($result, true, 'Multiple valid items in array'); $t->comment('->isFileInPlaylist( $playlist_id, $filename )'); $t->ok($playlist_files_table->isFileInPlaylist(1, 'file://localhost/home/music/song.mp3'), 'song is already in playlist 1'); $t->ok($playlist_files_table->isFileInPlaylist(1, 'file://localhost/home/music/song3.mp3'), 'song3 is already in playlist 1'); $t->is($playlist_files_table->isFileInPlaylist(2, 'file://localhost/home/music/song3.mp3'), false, 'song3 is not in playlist 2'); $t->comment('->deletePlaylistFile()'); $result4 = $playlist_files_table->deletePlaylistFile(1, '9ewf9ewjfa0jew90fejf9fje'); $t->is($result4, 1, 'removed a song from the playlist'); $t->comment('->deleteAllPlaylistFiles()'); $result = $playlist_files_table->deleteAllPlaylistFiles(1);
protected function _doMigrateStep($direction, $num) { parent::_doMigrateStep($direction, $num); $file = $this->getMigrationFixtureFile($num); if ($file) { Doctrine::loadData($file, true); } }
public function execute() { Doctrine::loadModels($this->getArgument('models_path')); Doctrine::loadData($this->getArgument('data_fixtures_path')); $this->dispatcher->notify('Data was successfully loaded'); }
include dirname(__FILE__) . '/../bootstrap/doctrine.php'; // Initialize the test object $t = new lime_test(20, new lime_output_color()); $album_table = Doctrine_Core::getTable('Album'); $t->comment('->addAlbum'); $first_insert_id = $album_table->addAlbum('með suð í eyrum við spilum endalaust'); $t->like($first_insert_id, '/\\d+/', 'Successfully added an album entry.'); $second_insert_id = $album_table->addAlbum('með suð í eyrum við spilum endalaust'); $t->is($first_insert_id, $second_insert_id, 'Updated an identical album entry.'); $third_insert_id = $album_table->addAlbum('gorillaz compilation'); $t->like($third_insert_id, '/\\d+/', 'Successfully added another album entry.'); $fourth_insert_id = $album_table->addAlbum('gorillaz compilation'); $t->is($third_insert_id, $fourth_insert_id, 'Updated an identical album entry for second album.'); $t->comment('->getList'); //add the required fixtures Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures/30_AlbumTable'); $list = $album_table->getList('all', 'all'); $count = count($list); $t->is($count, 2, 'Successfully listed all albums'); $list = $album_table->getList('g', 'all'); $count2 = count($list); $t->is($count2, 1, 'correct record count for alphabetical listing'); $t->is($list[0]['name'], 'gorillaz compilation', 'Successfully narrowed list by alphabetical character'); $list = $album_table->getList('G', 'all'); $count4 = count($list); $t->is($count4, 1, 'correct record count for alphabetical listing'); $t->is($list[0]['name'], 'gorillaz compilation', 'Alpha char is case insensitive'); $list = $album_table->getList('all', 1); $count3 = count($list); $t->is($count3, 1, 'correct record count for artist listing'); $t->is($list[0]['name'], 'með suð í eyrum við spilum endalaust', 'Successfully narrowed list by artist id');
public static function setUpBeforeClass() { parent::resetMongo(); Doctrine::loadData(dirname(__FILE__) . '/fixtures'); }
$third_insert_id = $song_table->addSong(null, null, null, null, $empty_test_song); $t->is($third_insert_id, null, 'Ignore Entry of an incomplete song record'); $fourth_insert_id = $song_table->addSong(2, 2, 1, $utf8_test_song); $t->like($fourth_insert_id, '/\\d+/', 'Successfully added a UTF-8 encoded entry'); $t->comment('->findByFilenameAndMtime'); $song = $song_table->findByFilenameAndMtime('file://localhost/home/notroot/music/test.mp3', '1299800000'); $t->is($song->id, 2, 'Fetch Record by filename and mtime'); $t->comment('->getSongByUniqueId'); $unique_song = $song_table->getSongByUniqueId($song->unique_id); $t->is($unique_song->id, 2, 'Fetch record by unique id'); $t->comment('->updateScanId()'); $affected_rows = $song_table->updateScanId('file://localhost/home/notroot/music/Fließgewässer.mp3', 1293300023, 2); $t->is($affected_rows, 1, 'Updated a song with a scan id'); $t->comment('->getUnscannedArtList'); //add the required fixtures Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures/10_SongTable'); $list = $song_table->getUnscannedArtList('amazon'); $count1 = count($list); $t->is($count1, 2, 'Got a list of unscanned art'); $t->comment('->getFileList'); $result = $song_table->getFileList('1', 'artist'); $count2 = count($result); $t->is($count2, 2, 'Got a file listing by artist'); $result = $song_table->getFileList('2', 'album'); $count3 = count($result); $t->is($count3, 1, 'Got a file listing by album'); $result = $song_table->getFileList($song->unique_id, 'song'); $count4 = count($result); $t->is($count4, 1, 'Got a file listing by song unique_id'); $t->comment('->getTotalSongCount'); $t->is($song_table->getTotalSongCount(), 3, 'correct total song count');
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::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'); }
<?php // guess current application $app = 'frontend'; include dirname(__FILE__) . '/unit.php'; include dirname(__FILE__) . '/functional.php'; new sfDatabaseManager($configuration); Doctrine::loadData(dirname(__FILE__) . '/../fixtures'); $conn = Doctrine_Manager::getInstance()->getCurrentConnection();
public function setUp() { //parent::resetMongo(); sfConfig::set('sf_environment', 'test'); Doctrine::loadData(dirname(__FILE__) . '/fixtures'); sfConfig::set('sf_environment', 'dev'); }
public function setUp() { parent::setUp(); $yamlPath = dirname(__FILE__) . '/fixtures/budget.yml'; Doctrine::loadData($yamlPath); }
<?php ob_start(); include dirname(__FILE__) . '/../bootstrap/doctrine.php'; // Initialize the test object $t = new lime_test(13, new lime_output_color()); //add the required fixtures Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures/90_ArtworkScanMeta/table.yml'); require_once dirname(__FILE__) . '/../../lib/task/scanners/artworkScanAmazon.php'; $artwork_base_dir = dirname(__FILE__) . '/../../data/album_art'; $message = ob_get_contents(); ob_end_clean(); /* Verify Files have been created for fixture mp3 */ if (is_readable($artwork_base_dir . '/9c33cc0dca6a07eaaaa0dc0fd23afc95')) { $t->pass('created hashed directory for fixture song'); } else { $t->fail('couldn\'t create the album art directory for fixture song'); } /* Verify Files have been created for fixture mp3 */ if (is_readable($artwork_base_dir . '/9c33cc0dca6a07eaaaa0dc0fd23afc95/small.jpg')) { $t->pass('created small thumbnail'); } else { $t->fail('couldn\'t create small thumbnail'); } /* Verify Files have been created for fixture mp3 */ if (is_readable($artwork_base_dir . '/9c33cc0dca6a07eaaaa0dc0fd23afc95/medium.jpg')) { $t->pass('created medium thumbnail'); } else { $t->fail('couldn\'t create medium thumbnail'); } /* Verify Files have been created for fixture mp3 */
public static function setUpBeforeClass() { Doctrine::loadData(dirname(__FILE__) . '/fixtures'); }
public function loadData() { Doctrine::loadData(sfConfig::get('sf_test_dir') . '/fixtures'); return $this; }
/** * Import fixtures from $path. If $append is true the database will not be purged * before importing. * * @param string $path * @param boolean $append * @return void */ public function importFixtures($path, $append = false) { $this->_loadDoctrineModels(); Doctrine::loadData($path, $append); }