本文整理汇总了PHP中Printer::maybeDeleted方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::maybeDeleted方法的具体用法?PHP Printer::maybeDeleted怎么用?PHP Printer::maybeDeleted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Printer
的用法示例。
在下文中一共展示了Printer::maybeDeleted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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);
}