本文整理汇总了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);
}
示例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');
//.........这里部分代码省略.........