You are here

function MonitoringUITest::testForceExecute in Monitoring 7

Tests the force execute all and sensor specific force execute links.

File

test/tests/monitoring.ui.test, line 217
Contains \MonitoringUITest.

Class

MonitoringUITest
Tests for the Monitoring UI.

Code

function testForceExecute() {
  $account = $this
    ->drupalCreateUser(array(
    'monitoring force run',
    'monitoring reports',
  ));
  $this
    ->drupalLogin($account);

  // Set a specific test sensor result to look for.
  $test_sensor_result_data = array(
    'sensor_message' => 'First message',
  );
  variable_set('test_sensor_result_data', $test_sensor_result_data);
  $this
    ->drupalGet('admin/reports/monitoring');
  $this
    ->assertText('First message');

  // Update the sensor message.
  $test_sensor_result_data['sensor_message'] = 'Second message';
  variable_set('test_sensor_result_data', $test_sensor_result_data);

  // Access the page again, we should still see the first message because the
  // cached result is returned.
  $this
    ->drupalGet('admin/reports/monitoring');
  $this
    ->assertText('First message');

  // Force sensor execution, the changed message should be displayed now.
  $this
    ->clickLink(t('Force execute all'));
  $this
    ->assertNoText('First message');
  $this
    ->assertText('Second message');

  // Update the sensor message again.
  $test_sensor_result_data['sensor_message'] = 'Third message';
  variable_set('test_sensor_result_data', $test_sensor_result_data);

  // Simulate a click on Force execution, there are many of those so we just
  // verify that such links exist and visit the path manually.
  $this
    ->assertLink(t('Force execution'));
  $this
    ->drupalGet('monitoring/sensors/force/test_sensor');
  $this
    ->assertNoText('Second message');
  $this
    ->assertText('Third message');
}