You are here

public function CacheFlushCronTest::testAddInterface in CacheFlush 7.3

Test add interface for cron functionality.

File

modules/cacheflush_cron/cacheflush_cron.test, line 52
Contains test suite for cacheflush cron module.

Class

CacheFlushCronTest
Defines a test for cacheflush Cron module.

Code

public function testAddInterface() {

  // Check interface.
  $this
    ->drupalGet('admin/structure/cacheflush/add');
  $this
    ->assertResponse(200);
  $this
    ->assertFieldByName('cacheflush_cron_sett');
  $this
    ->assertFieldByName('cacheflush_cron_rule');

  // Add new entity.
  $edit = array(
    'title' => 'CronTest1',
    'cacheflush_cron_sett' => TRUE,
    'cacheflush_cron_rule' => '*/5 * * * *',
  );
  $this
    ->drupalPost('admin/structure/cacheflush/add', $edit, t('Save'));

  // Load entity and check if cron sett.
  $entities = array_values(cacheflush_load_multiple(FALSE, array(
    'title' => 'CronTest1',
  )));
  $this
    ->assertEqual($entities[0]->cron, 1);
  $this
    ->assertEqual($entities[0]->cron_rule, '*/5 * * * *');

  // Check if entity was corectly create on EDIT interface.
  $this
    ->drupalGet('cacheflush/' . $entities[0]->id . '/edit');
  $this
    ->assertFieldByName('cacheflush_cron_sett', 1);
  $this
    ->assertLink(t('Cron Settings'));
  $this
    ->assertNoFieldByName('cacheflush_cron_rule');

  // Check if cron job created.
  $crons = elysia_cron_module_jobs();
  $this
    ->assertTrue($crons['cacheflush_entity_' . $entities[0]->id]);
}