You are here

public function AcquiaLiftTest::testGetCallsForPreviousMonth in Acquia Lift Connector 7

Test the testGetCallsForPreviousMonth() method.

File

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

Class

AcquiaLiftTest
@file Unit tests for Acquia Lift module.

Code

public function testGetCallsForPreviousMonth() {
  $lift_api = $this
    ->getAcquiaLiftAPI();

  // Make sure we're starting off when a clean request log in our dummy
  // http client.
  DummyAcquiaLiftHttpClient::clearLoggedRequests();
  $timestamps = array(
    // Timestamp representing March 12th 2014
    1394652611 => array(
      'start' => '2014-02-01',
      'end' => '2014-02-28',
    ),
    // Timestamp representing January 2nd 2014
    1388695528 => array(
      'start' => '2013-12-01',
      'end' => '2013-12-31',
    ),
    // Timestamp representing December 31st 2013
    1388522626 => array(
      'start' => '2013-11-01',
      'end' => '2013-11-30',
    ),
    // Timestamp representing October 9th 2013
    1381348094 => array(
      'start' => '2013-09-01',
      'end' => '2013-09-30',
    ),
  );
  foreach ($timestamps as $timestamp => $expected_dates) {
    $count = $lift_api
      ->getCallsForPreviousMonth($timestamp);

    // Define the requests we expect to have been made to our dummy http
    // client for this operation.
    $requests = array(
      array(
        'type' => 'get',
        'uri' => "http://api.lift.acquia.com/{$this->liftOwnerCode}/-/report/system-usage/{$expected_dates['start']}/{$expected_dates['end']}?apikey={$this->liftAdminKey}",
        'headers' => array(
          'Accept' => 'application/json',
        ),
        'options' => array(),
        'body' => NULL,
      ),
    );

    // Confirm the expected requests were made.
    $this
      ->assertAPIRequests($requests);
  }
}