CourierMaintenanceFormTest.php in Courier 8
File
src/Tests/CourierMaintenanceFormTest.php
View source
<?php
namespace Drupal\courier\Tests;
use Drupal\Core\Url;
use Drupal\courier\Entity\MessageQueueItem;
use Drupal\simpletest\WebTestBase;
class CourierMaintenanceFormTest extends WebTestBase {
public static $modules = [
'courier',
];
public function testMessageDelete() {
$user = $this
->drupalCreateUser([
'administer courier',
]);
$this
->drupalLogin($user);
MessageQueueItem::create([
'created' => REQUEST_TIME + 3600,
])
->save();
MessageQueueItem::create([
'created' => REQUEST_TIME + 3600,
])
->save();
MessageQueueItem::create([
'created' => REQUEST_TIME + 3600,
])
->save();
MessageQueueItem::create([
'created' => REQUEST_TIME - 3600,
])
->save();
MessageQueueItem::create([
'created' => REQUEST_TIME - 3600,
])
->save();
$edit = [
'delete_age' => 60,
];
$this
->drupalPostForm(Url::fromRoute('courier.admin.maintenance'), $edit, t('Delete messages'));
$this
->assertRaw('2 messages deleted.');
}
}