本文整理汇总了PHP中Printer::restore方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::restore方法的具体用法?PHP Printer::restore怎么用?PHP Printer::restore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Printer
的用法示例。
在下文中一共展示了Printer::restore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPrinter
/**
* Check delete / purge on a pinter
*/
public function testPrinter()
{
$printer = new Printer();
// Create
$id[0] = $printer->add(array('name' => "Printer", 'entities_id' => 0, 'is_template' => 0));
$this->assertGreaterThan(0, $id[0], "Fail to create Printer 1");
$this->assertTrue($printer->getFromDB($id[0]), "Fail: can't read Printer");
// Verify DB Schema have not change
$this->assertArrayHasKey('is_deleted', $printer->fields, "Fail: no is_deleted field");
$this->assertArrayHasKey('is_template', $printer->fields, "Fail: no is_template field");
$this->assertEquals(0, $printer->fields['is_deleted'], "Fail: is_deleted set");
$this->assertEquals(0, $printer->fields['is_template'], "Fail: is_template set");
// Delete
$this->assertTrue($printer->delete(array('id' => $id[0])), "Fail: can't delete Printer");
$this->assertTrue($printer->getFromDB($id[0]), "Fail: can't read Printer");
$this->assertEquals(1, $printer->fields['is_deleted'], "Fail: is_deleted not set");
// Restore
$this->assertTrue($printer->restore(array('id' => $id[0])), "Fail: can't restore Printer");
$this->assertTrue($printer->getFromDB($id[0]), "Fail: can't read Printer");
$this->assertEquals(0, $printer->fields['is_deleted'], "Fail: is_deleted set");
// Delete again
$this->assertTrue($printer->delete(array('id' => $id[0])), "Fail: can't delete Printer");
$this->assertTrue($printer->getFromDB($id[0]), "Fail: can't read Printer");
$this->assertEquals(1, $printer->fields['is_deleted'], "Fail: is_deleted not set");
// Purge
$this->assertTrue($printer->delete(array('id' => $id[0]), 1), "Fail: to purge Printer");
$this->assertFalse($printer->getFromDB($id[0]), "Fail: can read Printer (purged)");
}
示例2: testDelete
/**
* @covers Printer::delete
* @covers Printer::restore
*/
public function testDelete()
{
$obj = new Printer();
$this->assertTrue($obj->maybeDeleted());
// Add
$id = $obj->add(['name' => __METHOD__]);
$this->assertGreaterThan(0, $id);
$this->assertTrue($obj->getFromDB($id));
$this->assertEquals(0, $obj->getField('is_deleted'));
$this->assertEquals(0, $obj->isDeleted());
// Delete
$this->assertTrue($obj->delete(['id' => $id], 0));
$this->assertTrue($obj->getFromDB($id));
$this->assertEquals(1, $obj->getField('is_deleted'));
$this->assertEquals(1, $obj->isDeleted());
// Restore
$this->assertTrue($obj->restore(['id' => $id], 0));
$this->assertTrue($obj->getFromDB($id));
$this->assertEquals(0, $obj->getField('is_deleted'));
$this->assertEquals(0, $obj->isDeleted());
// Purge
$this->assertTrue($obj->delete(['id' => $id], 1));
$this->assertFalse($obj->getFromDB($id));
}
示例3:
if (isset($_POST["add"])) {
$print->check(-1, 'w', $_POST);
if ($newID = $print->add($_POST)) {
Event::log($newID, "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " " . $_POST["name"] . ".");
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["delete"])) {
$print->check($_POST["id"], 'd');
$print->delete($_POST);
Event::log($_POST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][22]);
$print->redirectToList();
} else {
if (isset($_POST["restore"])) {
$print->check($_POST["id"], 'd');
$print->restore($_POST);
Event::log($_POST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][23]);
$print->redirectToList();
} else {
if (isset($_REQUEST["purge"])) {
$print->check($_REQUEST["id"], 'd');
$print->delete($_REQUEST, 1);
Event::log($_REQUEST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][24]);
$print->redirectToList();
} else {
if (isset($_POST["update"])) {
$print->check($_POST["id"], 'w');
$print->update($_POST);
Event::log($_POST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
glpi_header($_SERVER['HTTP_REFERER']);
} else {
示例4: testDeleteByCriteria
/**
* @covers Printer::deleteByCriteria
* @covers Printer::restore
*/
public function testDeleteByCriteria()
{
$obj = new Printer();
$this->assertTrue($obj->maybeDeleted());
// Add
$id = $obj->add(['name' => __METHOD__, 'entities_id' => getItemByTypeName('Entity', '_test_root_entity', true)]);
$this->assertGreaterThan(0, $id);
$this->assertTrue($obj->getFromDB($id));
$this->assertEquals(0, $obj->getField('is_deleted'));
$this->assertEquals(0, $obj->isDeleted());
$nb_before = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n AND items_id = '{$id}'");
// DeleteByCriteria without history
$this->assertTrue($obj->deleteByCriteria(['name' => __METHOD__], 0, 0));
$this->assertTrue($obj->getFromDB($id));
$this->assertEquals(1, $obj->getField('is_deleted'));
$this->assertEquals(1, $obj->isDeleted());
$nb_after = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n AND items_id = '{$id}'");
$this->assertEquals($nb_before, $nb_after);
// Restore
$this->assertTrue($obj->restore(['id' => $id], 0));
$this->assertTrue($obj->getFromDB($id));
$this->assertEquals(0, $obj->getField('is_deleted'));
$this->assertEquals(0, $obj->isDeleted());
$nb_before = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n AND items_id = '{$id}'");
// DeleteByCriteria with history
$this->assertTrue($obj->deleteByCriteria(['name' => __METHOD__], 0, 1));
$this->assertTrue($obj->getFromDB($id));
$this->assertEquals(1, $obj->getField('is_deleted'));
$this->assertEquals(1, $obj->isDeleted());
$nb_after = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n AND items_id = '{$id}'");
$this->assertEquals($nb_before + 1, $nb_after);
}