You are here

function ServicesResourceSystemTests::testSystemGetVariable in Services 7.3

Same name and namespace in other branches
  1. 6.3 tests/functional/ServicesResourceSystemTests.test \ServicesResourceSystemTests::testSystemGetVariable()

Test get_variable method.

File

tests/functional/ServicesResourceSystemTests.test, line 67
Call the endpoint tests when no authentication is being used.

Class

ServicesResourceSystemTests
Run test cases for the endpoint with no authentication turned on.

Code

function testSystemGetVariable() {
  $path = $this->endpoint->path;
  $name = $this
    ->randomName();
  $value = $this
    ->randomString();
  variable_set($name, $value);

  // Get already set variable.
  $response = $this
    ->servicesPost($path . '/system/get_variable', array(
    'name' => $name,
    'default' => $this
      ->randomString(),
  ));
  $this
    ->assertEqual($value, $response['body'], 'Variable get value.', 'SystemResource: get_variable');
  $name = $this
    ->randomName();
  $default = $this
    ->randomString();

  // Get not defined variable. Ensure we get back default value.
  $response = $this
    ->servicesPost($path . '/system/get_variable', array(
    'name' => $name,
    'default' => $default,
  ));
  $this
    ->assertEqual($default, $response['body'], 'Variable get value default.', 'SystemResource: get_variable');
}