本文整理汇总了PHP中Software::removeFromTrash方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::removeFromTrash方法的具体用法?PHP Software::removeFromTrash怎么用?PHP Software::removeFromTrash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::removeFromTrash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSoftwareCategory
/**
* Test software category Rule and putInTrash / removeFromTrash
*/
public function testSoftwareCategory()
{
global $CFG_GLPI;
$ent0 = $this->sharedFixture['entity'][0];
// Clean preload rules
$tmp = SingletonRuleList::getInstance('RuleSoftwareCategory');
$tmp->load = 0;
$this->assertArrayHasKey('softwarecategories_id_ondelete', $CFG_GLPI, "Fail: no softwarecategories_id_ondelete");
$idcat[0] = Dropdown::import('SoftwareCategory', array('name' => 'Trashed'));
$this->assertGreaterThan(0, $idcat[0], "Fail: can't create SoftwareCategory");
$idcat[1] = Dropdown::import('SoftwareCategory', array('name' => 'OpenSource'));
$this->assertGreaterThan(0, $idcat[1], "Fail: can't create SoftwareCategory");
$rule = new RuleSoftwareCategory();
$crit = new RuleCriteria();
$acte = new RuleAction();
$idr[0] = $rule->add(array('name' => 'OSS', 'sub_type' => 'RuleSoftwareCategory', 'match' => 'AND', 'is_active' => 1));
$this->assertGreaterThan(0, $idr[0], "Fail: can't create rule 1");
$this->assertTrue($rule->getFromDB($idr[0]));
$this->assertEquals(1, $rule->fields['ranking'], "Fail: ranking not set");
$idc[0] = $crit->add(array('rules_id' => $idr[0], 'criteria' => 'manufacturer', 'condition' => Rule::PATTERN_IS, 'pattern' => 'Indepnet'));
$this->assertGreaterThan(0, $idc[0], "Fail: can't create rule 1 criteria");
$ida[0] = $acte->add(array('rules_id' => $idr[0], 'action_type' => 'assign', 'field' => 'softwarecategories_id', 'value' => $idcat[1]));
$this->assertGreaterThan(0, $ida[0], "Fail: can't create rule 1 action");
// Createthe software
$soft = new Software();
$id[0] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent0);
$this->assertGreaterThan(0, $id[0], "Fail: can't create software 1");
// Check name
$this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
$this->assertEquals('GLPI', $soft->getField('name'), "Fail: name not set");
// Check category
$catid = $soft->getField('softwarecategories_id');
$this->assertEquals($idcat[1], $catid, "Fail: category not set");
// Change configuration
$CFG_GLPI["softwarecategories_id_ondelete"] = $idcat[0];
// Delete
$this->assertTrue($soft->putInTrash($id[0]), "Fail: can't put soft in trash");
$this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
$catid = $soft->getField('softwarecategories_id');
$this->assertEquals($idcat[0], $catid, "Fail: category not set");
$this->assertEquals(1, $soft->getField('is_deleted'), "Fail: soft not deleted");
// Restore
$this->assertTrue($soft->removeFromTrash($id[0]), "Fail: can't put soft in trash");
$this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
$catid = $soft->getField('softwarecategories_id');
$this->assertEquals($idcat[1], $catid, "Fail: category not set");
$this->assertEquals(0, $soft->getField('is_deleted'), "Fail: soft not restored");
// Clean
$this->assertTrue($soft->delete(array('id' => $id[0]), true), "Fail: can't delete software 1)");
}