function testLoad() { $created = Pluf_Test_Fixture::load('[{"model":"Pluf_Permission","pk":1,"fields":{"id":1,"name":"test permission","code_name":"test","description":"Simple test permission.","application":"Pluf"}}]'); $this->assertEqual(array(array('Pluf_Permission', '1')), $created); $p = new Pluf_Permission(1); $this->assertEqual(1, $p->id); }
/** * Restore Pluf from a backup. * * @param string Path to the backup folder * @param string Backup name * @return bool Success */ function Pluf_Migrations_Backup_restore($folder, $name) { $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(); $schema = new Pluf_DB_Schema($db); foreach ($models as $model) { $schema->model = new $model(); $schema->createTables(); } $full_data = json_decode(file_get_contents(sprintf('%s/%s-Pluf.json', $folder, $name)), true); foreach ($full_data as $model => $data) { Pluf_Test_Fixture::load($data, false); } return true; }
/** * Restore IDF from a backup. * * @param string Path to the backup folder * @param string Backup name * @return bool Success */ function IDF_Migrations_Backup_restore($folder, $name) { $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(); $schema = new Pluf_DB_Schema($db); foreach ($models as $model) { $schema->model = new $model(); $schema->createTables(); } $full_data = json_decode(file_get_contents(sprintf('%s/%s-IDF.json', $folder, $name)), true); foreach ($full_data as $model => $data) { Pluf_Test_Fixture::load($data, false); } return true; }
exit(1); } define('SIMPLE_TEST', $simple_test . '/'); require_once SIMPLE_TEST . 'unit_tester.php'; require_once SIMPLE_TEST . 'reporter.php'; $files = getTestFiles($testfolder); $dirs = getTestDirs($testfolder); foreach ($dirs as $dir) { foreach (getTestFiles($dir) as $test) { $files[] = $test; } } $test =& new GroupTest(sprintf('All tests for application %s.', $app)); foreach ($files as $t) { if (!function_exists('apc_store') && 'Pluf_Tests_Cache_Apc' === $t[1]) { continue; } $test->addTestCase(new $t[1]()); } $reporter = new TextReporter(); $mig = new Pluf_Migration(null); $mig->display = false; $mig->install(); // If available, load an initialisation file. if (file_exists($app . '/Tests/init.json')) { $created = Pluf_Test_Fixture::loadFile($app . '/Tests/init.json'); } else { $created = array(); } $test->run($reporter); $mig->unInstall();