當前位置: 首頁>>代碼示例>>PHP>>正文


PHP backup_nested_element::process方法代碼示例

本文整理匯總了PHP中backup_nested_element::process方法的典型用法代碼示例。如果您正苦於以下問題:PHP backup_nested_element::process方法的具體用法?PHP backup_nested_element::process怎麽用?PHP backup_nested_element::process使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在backup_nested_element的用法示例。


在下文中一共展示了backup_nested_element::process方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process

 public function process($processor)
 {
     // Get current backupid from processor, we'll need later
     if (is_null($this->backupid)) {
         $this->backupid = $processor->get_var(backup::VAR_BACKUPID);
     }
     return parent::process($processor);
 }
開發者ID:bobpuffer,項目名稱:moodleUCLA-LUTH,代碼行數:8,代碼來源:backup_custom_fields.php

示例2: catch

 /**
  * Backup structures wrong tests (trying to do things the wrong way)
  */
 function test_backup_structure_wrong()
 {
     // Instantiate the backup processor
     $processor = new backup_structure_processor(new xml_writer(new memory_xml_output()));
     $this->assertTrue($processor instanceof base_processor);
     // Set one var twice
     $processor->set_var('onenewvariable', 999);
     try {
         $processor->set_var('onenewvariable', 999);
         $this->assertTrue(false, 'backup_processor_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof backup_processor_exception);
         $this->assertEquals($e->errorcode, 'processorvariablealreadyset');
         $this->assertEquals($e->a, 'onenewvariable');
     }
     // Get non-existing var
     try {
         $var = $processor->get_var('nonexistingvar');
         $this->assertTrue(false, 'backup_processor_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof backup_processor_exception);
         $this->assertEquals($e->errorcode, 'processorvariablenotfound');
         $this->assertEquals($e->a, 'nonexistingvar');
     }
     // Create nested element and try ro get its parent id (doesn't exisit => exception)
     $ne = new backup_nested_element('test', 'one', 'two', 'three');
     try {
         $ne->set_source_table('forum', array('id' => backup::VAR_PARENTID));
         $ne->process($processor);
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'cannotfindparentidforelement');
     }
     // Try to process one nested/final/attribute elements without processor
     $ne = new backup_nested_element('test', 'one', 'two', 'three');
     try {
         $ne->process(new stdclass());
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'incorrect_processor');
     }
     $fe = new backup_final_element('test');
     try {
         $fe->process(new stdclass());
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'incorrect_processor');
     }
     $at = new backup_attribute('test');
     try {
         $at->process(new stdclass());
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'incorrect_processor');
     }
     // Try to put an incorrect alias
     $ne = new backup_nested_element('test', 'one', 'two', 'three');
     try {
         $ne->set_source_alias('last', 'nonexisting');
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'incorrectaliasfinalnamenotfound');
         $this->assertEquals($e->a, 'nonexisting');
     }
     // Try various incorrect paths specifying source
     $ne = new backup_nested_element('test', 'one', 'two', 'three');
     try {
         $ne->set_source_table('forum', array('/test/subtest'));
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'baseelementincorrectfinalorattribute');
         $this->assertEquals($e->a, 'subtest');
     }
     try {
         $ne->set_source_table('forum', array('/wrongtest'));
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'baseelementincorrectgrandparent');
         $this->assertEquals($e->a, 'wrongtest');
     }
     try {
         $ne->set_source_table('forum', array('../nonexisting'));
         $this->assertTrue(false, 'base_element_struct_exception expected');
     } catch (exception $e) {
         $this->assertTrue($e instanceof base_element_struct_exception);
         $this->assertEquals($e->errorcode, 'baseelementincorrectparent');
         $this->assertEquals($e->a, '..');
     }
     // Try various incorrect file annotations
     $ne = new backup_nested_element('test', 'one', 'two', 'three');
//.........這裏部分代碼省略.........
開發者ID:bobpuffer,項目名稱:moodleUCLA-LUTH,代碼行數:101,代碼來源:structure_test.php


注:本文中的backup_nested_element::process方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。