public function testAddDelete()
{
$alert = new Alert();
$nb = countElementsInTable($alert->getTable());
$comp = getItemByTypeName('Computer', '_test_pc01');
$date = '2016-09-01 12:34:56';
// Add
$id = $alert->add(['itemtype' => $comp->getType(), 'items_id' => $comp->getID(), 'type' => Alert::END, 'date' => $date]);
$this->assertGreaterThan(0, $id);
$this->assertGreaterThan($nb, countElementsInTable($alert->getTable()));
// Getters
$this->assertFalse(Alert::alertExists($comp->getType(), $comp->getID(), Alert::NOTICE));
$this->assertEquals($id, Alert::alertExists($comp->getType(), $comp->getID(), Alert::END));
$this->assertEquals($date, Alert::getAlertDate($comp->getType(), $comp->getID(), Alert::END));
// Display
$this->expectOutputString(sprintf('Alert sent on %s', Html::convDateTime($date)));
Alert::displayLastAlert($comp->getType(), $comp->getID());
// Delete
$this->assertTrue($alert->clear($comp->getType(), $comp->getID(), Alert::END));
$this->assertEquals($nb, countElementsInTable($alert->getTable()));
// Still true, nothing to delete but no error
$this->assertTrue($alert->clear($comp->getType(), $comp->getID(), Alert::END));
}