You are here

public function AcquiaLiftTest::testGetAgent in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 tests/AcquiaLiftAPI.test \AcquiaLiftTest::testGetAgent()

Test AcquiaLiftAPI->getAgent()

File

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

Class

AcquiaLiftTest
@file Unit tests for Acquia Lift module.

Code

public function testGetAgent() {
  $lift_api = $this
    ->getAcquiaLiftAPI();
  $machineName = 'some_machine_name';
  $lift_api
    ->getAgent($machineName);

  // 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()}/agent-api/{$machineName}?apikey={$lift_api->getAdminKey()}",
      'headers' => array(
        'Accept' => 'application/json',
      ),
      'options' => array(),
      'body' => NULL,
    ),
  );

  // Confirm the expected requests and logs.
  $this
    ->assertAPIRequests($requests);
  $logs = array();
  $this
    ->assertLogs($logs);
  $lift_api = $this
    ->getAcquiaLiftAPI(TRUE);
  try {
    $lift_api
      ->getAgent($machineName);
    $this
      ->fail('Should not reach here');
  } catch (AcquiaLiftException $e) {
  }

  // Confirm the expected requests and logs.
  $this
    ->assertAPIRequests($requests);
  $logs = array();
  $this
    ->assertLogs($logs);
}