You are here

function AcquiaLiftWebTestWorkflow::testVerificationChecks in Acquia Lift Connector 7

Tests the effect of the acquia_lift_unibar_allow_status_change variable to prevent verification checks on every page load.

File

tests/acquia_lift.test, line 3072
Integration tests for Acquia Lift module.

Class

AcquiaLiftWebTestWorkflow

Code

function testVerificationChecks() {
  module_load_include('inc', 'acquia_lift', 'acquia_lift.ui');
  AcquiaLiftAPI::setTestInstance();

  // Create a bunch of agents.
  $num_agents = 10;
  for ($i = 0; $i < $num_agents; $i++) {
    $this
      ->createTestAgent(array(
      'control_rate' => 10,
      'explore_rate' => 30,
    ));
  }
  $this
    ->resetAll();
  DummyAcquiaLiftHttpClient::clearLoggedRequests();
  $page = array(
    'page_top' => array(),
  );
  acquia_lift_build_page($page);

  // There should be 3 requests per agent, and there are 11 agents (the 10 we
  // just created plus the default.)
  $requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
  $this
    ->assertEqual(count($requests), 3 + 3 * $num_agents);

  // Don't clear cache but clear logged requests and call the function again,
  // there shouldn't be any new requests.
  DummyAcquiaLiftHttpClient::clearLoggedRequests();
  acquia_lift_build_page($page);
  $requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
  $this
    ->assertEqual(count($requests), 0);

  // Clear the cache and confirm they are made again.
  $this
    ->resetAll();
  DummyAcquiaLiftHttpClient::clearLoggedRequests();
  acquia_lift_build_page($page);
  $requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
  $this
    ->assertEqual(count($requests), 3 + 3 * $num_agents);

  // Now disable allowing status changes from the unibar.
  variable_set('acquia_lift_unibar_allow_status_change', 0);
  $this
    ->resetAll();
  DummyAcquiaLiftHttpClient::clearLoggedRequests();
  acquia_lift_build_page($page);
  $requests = DummyAcquiaLiftHttpClient::getLoggedRequests();
  $this
    ->assertEqual(count($requests), 0);
}