You are here

public function CacheFlushCronTest::testEditInterface in CacheFlush 7.3

Test edit interface for cron functionality.

File

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

Class

CacheFlushCronTest
Defines a test for cacheflush Cron module.

Code

public function testEditInterface() {

  // Entity create by code with no cron set. Check if true.
  $this
    ->drupalGet('cacheflush/' . $this->eid . '/edit');
  $this
    ->assertFieldByName('cacheflush_cron_sett', 0);
  $this
    ->assertFieldByName('cacheflush_cron_rule', '* * * * *');
  $this
    ->assertNoLink(t('Cron Settings'));

  // Add cron on the edit page for an entity create without cron settings.
  $edit = array(
    'cacheflush_cron_sett' => TRUE,
    'cacheflush_cron_rule' => '*/5 * * * *',
  );
  $this
    ->drupalPost(NULL, $edit, t('Update'));

  // Load entity and check if cron sett.
  $entities = array_values(cacheflush_load_multiple(FALSE, array(
    'title' => 'CronTest2',
  )));
  $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/' . $this->eid . '/edit');
  $this
    ->assertFieldByName('cacheflush_cron_sett', 1);
  $this
    ->assertLink(t('Cron Settings'));
  $this
    ->assertNoFieldByName('cacheflush_cron_rule');

  // Remove cron settings and check if interface got back to normal.
  $edit = array(
    'cacheflush_cron_sett' => FALSE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Update'));
  $this
    ->drupalGet('cacheflush/' . $this->eid . '/edit');
  $this
    ->assertResponse(200);
  $this
    ->assertFieldByName('cacheflush_cron_sett', 0);
  $this
    ->assertFieldByName('cacheflush_cron_rule', '* * * * *');
}