You are here

public function AcquiaLiftTest::testPingTest in Acquia Lift Connector 7

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

Test AcquiaLiftAPI->pingTest()

File

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

Class

AcquiaLiftTest
@file Unit tests for Acquia Lift module.

Code

public function testPingTest() {
  $lift_api = $this
    ->getAcquiaLiftAPI();
  $ping_test = $lift_api
    ->pingTest();
  $this
    ->assertTrue($ping_test);
  $expected = array(
    array(
      'type' => 'get',
      'uri' => "{$lift_api->getApiUrl()}/{$lift_api->getOwnerCode()}/list-agents?apikey={$lift_api->getAdminKey()}",
      'headers' => array(
        'Accept' => 'application/json',
      ),
      'options' => array(),
      'body' => NULL,
    ),
    array(
      'type' => 'post',
      'uri' => "{$lift_api->getApiUrl()}/{$lift_api->getOwnerCode()}/ping-test-agent/expire?apikey={$lift_api->getApiKey()}",
      'headers' => array(
        'Accept' => 'application/json',
      ),
      'options' => array(),
      'body' => NULL,
    ),
  );
  $this
    ->assertAPIRequests($expected);

  // Now test with a broken connection.
  $lift_api = $this
    ->getAcquiaLiftAPI(TRUE);
  $ping_test = $lift_api
    ->pingTest();
  $this
    ->assertFALSE($ping_test);
  $this
    ->assertAPIRequests($expected);
}