You are here

public function AcquiaLiftTest::testGetAgentStatusReport in Acquia Lift Connector 7

Test AcquiaLiftAPI->getAgentStatusReport()

File

tests/AcquiaLiftAPI.test, line 1308
Unit tests for Acquia Lift module.

Class

AcquiaLiftTest
@file Unit tests for Acquia Lift module.

Code

public function testGetAgentStatusReport() {
  $lift_api = $this
    ->getAcquiaLiftAPI();
  $agentNamesArray = array(
    'some-agent-name',
    'some-another-name',
  );
  $agentNames = 'some-agent-name,some-another-name';
  $dayNumber = 10;
  $lift_api
    ->getAgentStatusReport($agentNamesArray, $dayNumber);

  // Define the requests we expect to have been made to our dummy http
  // client for this operation.
  $requests = array(
    array(
      'type' => 'get',
      'uri' => "{$lift_api->getApiUrl()}/{$lift_api->getOwnerCode()}/report/status?codes={$agentNames}&days={$dayNumber}&apikey={$lift_api->getAdminKey()}",
      'headers' => array(
        'Accept' => 'application/json',
      ),
      'options' => array(),
      'body' => NULL,
    ),
  );

  // Confirm the expected requests were made.
  $this
    ->assertAPIRequests($requests);
  $logs = array();
  $this
    ->assertLogs($logs);
  $lift_api = $this
    ->getAcquiaLiftAPI(TRUE);
  try {
    $lift_api
      ->getAgentStatusReport($agentNamesArray, $dayNumber);
  } catch (Exception $e) {
    $this
      ->assertTrue($e instanceof AcquiaLiftException);
  }

  // Confirm the expected requests were made.
  $this
    ->assertAPIRequests($requests);
  $logs = array(
    array(
      'level' => PersonalizeLogLevel::ERROR,
      'message' => 'Problem retrieving status report.',
    ),
  );
  $this
    ->assertLogs($logs);
}