You are here

function ServicesResourceSystemTests::testSystemGetVariable in Services 6.3

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

Test get_variable method.

File

tests/functional/ServicesResourceSystemTests.test, line 70

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'], t('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'], t('Variable get value default.'), 'SystemResource: get_variable');
}