advancedqueue.test in Advanced Queue 7
File
tests/advancedqueue.test
View source
<?php
require_once 'advancedqueue_test.inc';
class AdvancedQueueTestCase extends QueueTestCase {
public static function getInfo() {
return array(
'name' => 'Advanced queue',
'description' => 'Validate that a Advanced Queue works as a normal queue.',
'group' => 'Advanced Queue',
);
}
function setUp() {
parent::setUp('advancedqueue');
variable_set('queue_default_class', 'AdvancedQueue');
}
}
class AdvancedQueueCronTestCase extends DrupalWebTestCase {
protected $admin_user;
public static function getInfo() {
return array(
'name' => 'Cron functionality',
'description' => 'Workers called by cron, and admin options.',
'group' => 'Advanced Queue',
);
}
function setUp() {
parent::setup('advancedqueue_test');
variable_set('queue_default_class', 'AdvancedQueue');
$this->admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
));
}
function testCronWorker() {
$data = advancedqueue_test_populate_two_queues();
variable_set('advancedqueue_use_cron', TRUE);
$this
->cronRun();
$count = 0;
foreach ($data as $item) {
$count += advancedqueue_test_count_watchdog('advancedqueue_test', 'advancedqueue_test_worker(@item)', array(
'@item' => print_r($item, TRUE),
), WATCHDOG_INFO);
}
$this
->assertEqual($count, 8, t('All queued items sent to worker.'));
}
function testAdminOption() {
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/config/system/cron');
$this
->assertField('edit-advancedqueue-use-cron', t('Advancedqueue use cron option.'));
$this
->assertNoFieldChecked('edit-advancedqueue-use-cron', t('Advancedqueue use cron option default unchecked.'));
$edit = array(
'advancedqueue_use_cron' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Save configuration'));
$this
->assertFieldChecked('edit-advancedqueue-use-cron', t('Advancedqueue cron enabled successfully.'));
$this
->drupalLogout();
}
}