You are here

function ServicesResourceSystemTests::testSystemDelVariable in Services 6.3

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

Test set_variable method.

File

tests/functional/ServicesResourceSystemTests.test, line 108

Class

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

Code

function testSystemDelVariable() {
  $path = $this->endpoint->path;

  // Set a random variable.
  $name = $this
    ->randomName();
  $value = $this
    ->randomString();
  variable_set($name, $value);

  // Delete the variable via del_variable.
  $response = $this
    ->servicesPost($path . '/system/del_variable', array(
    'name' => $name,
  ));

  // We can't use variable_get as variables get cached to global variable.
  $newvalue = $this
    ->randomString();
  $response = $this
    ->servicesPost($path . '/system/get_variable', array(
    'name' => $name,
    'default' => $newvalue,
  ));
  $this
    ->assertEqual($newvalue, $response['body'], t('Variable deleted.'), 'SystemResource: get_variable');
}