function testDump() { $p = new Pluf_Permission(); $p->name = 'test permission'; $p->code_name = 'test'; $p->description = 'Simple test permission.'; $p->application = 'Pluf'; $p->create(); $json = Pluf_Test_Fixture::dump('Pluf_Permission'); $this->assertEqual('[{"model":"Pluf_Permission","pk":1,"fields":{"id":1,"name":"test permission","code_name":"test","description":"Simple test permission.","application":"Pluf"}}]', $json); }
/** * Backup of the Plume Framework. * * Backup all the data of the framework models. By default the backup * name will be the date YYYY-MM-DD. * * @param string Path to the folder where to store the backup * @param string Name of the backup (null) * @return int The backup was correctly written */ function Pluf_Migrations_Backup_run($folder, $name = null) { $models = array('Pluf_DB_SchemaInfo', 'Pluf_Session', Pluf::f('pluf_custom_user', 'Pluf_User'), Pluf::f('pluf_custom_group', 'Pluf_Group'), 'Pluf_Message', 'Pluf_Permission', 'Pluf_RowPermission', 'Pluf_Search_Word', 'Pluf_Search_Occ', 'Pluf_Search_Stats', 'Pluf_Queue'); $db = Pluf::db(); // Now, for each table, we dump the content in json, this is a // memory intensive operation $to_json = array(); foreach ($models as $model) { $to_json[$model] = Pluf_Test_Fixture::dump($model, false); } if (null == $name) { $name = date('Y-m-d'); } return file_put_contents(sprintf('%s/%s-Pluf.json', $folder, $name), json_encode($to_json), LOCK_EX); }
/** * Backup of InDefero. * * !! You need also to backup Pluf if you want the full backup. !! * * @param string Path to the folder where to store the backup * @param string Name of the backup (null) * @return int The backup was correctly written */ function IDF_Migrations_Backup_run($folder, $name = null) { $models = array('IDF_Project', 'IDF_Tag', 'IDF_Issue', 'IDF_IssueComment', 'IDF_Conf', 'IDF_Upload', 'IDF_Search_Occ', 'IDF_IssueFile', 'IDF_Commit', 'IDF_Timeline', 'IDF_WikiPage', 'IDF_WikiRevision', 'IDF_Review', 'IDF_Review_Patch', 'IDF_Review_Comment', 'IDF_Review_FileComment', 'IDF_Key', 'IDF_Scm_Cache_Git', 'IDF_Queue', 'IDF_Gconf'); $db = Pluf::db(); // Now, for each table, we dump the content in json, this is a // memory intensive operation $to_json = array(); foreach ($models as $model) { $to_json[$model] = Pluf_Test_Fixture::dump($model, false); } if (null == $name) { $name = date('Y-m-d'); } return file_put_contents(sprintf('%s/%s-IDF.json', $folder, $name), json_encode($to_json), LOCK_EX); }