public function ServicesAliasTests::setUp in Services 7.3
Sets up a Drupal site for running functional and integration tests.
Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides ServicesWebTestCase::setUp
See also
DrupalWebTestCase::prepareDatabasePrefix()
DrupalWebTestCase::changeDatabasePrefix()
DrupalWebTestCase::prepareEnvironment()
File
- tests/
functional/ ServicesAliasTests.test, line 18 - Test to confirm Aliases functionality.
Class
- ServicesAliasTests
- Test case class for Alias tests.
Code
public function setUp(array $modules = array()) {
parent::setUp($modules);
$edit = $this
->populateEndpointFAPI();
$endpoint = new stdClass();
$endpoint->disabled = FALSE;
$endpoint->api_version = 3;
$endpoint->name = $edit['name'];
$endpoint->server = $edit['server'];
$endpoint->path = $edit['path'];
$endpoint->authentication = array(
'services' => 'services',
);
$endpoint->server_settings = array(
'formatters' => array(
'json' => TRUE,
'bencode' => TRUE,
'rss' => TRUE,
'plist' => TRUE,
'xmlplist' => TRUE,
'php' => TRUE,
'yaml' => TRUE,
'jsonp' => FALSE,
'xml' => FALSE,
),
'parsers' => array(
'application/x-yaml' => TRUE,
'application/json' => TRUE,
'application/vnd.php.serialized' => TRUE,
'application/plist' => TRUE,
'application/plist+xml' => TRUE,
'application/x-www-form-urlencoded' => TRUE,
'multipart/form-data' => TRUE,
),
);
$endpoint->resources = array(
'user' => array(
'alias' => 'user-alias',
'actions' => array(
'login' => array(
'enabled' => 1,
'settings' => array(
'services' => array(
'resource_api_version' => '1.1',
),
),
),
),
),
'node' => array(
'alias' => 'node_alias',
'operations' => array(
'retrieve' => array(
'enabled' => 1,
),
),
),
);
$endpoint->debug = 1;
$endpoint->export_type = FALSE;
services_endpoint_save($endpoint);
$endpoint = services_endpoint_load($endpoint->name);
$this
->assertTrue($endpoint->name == $edit['name'], 'Endpoint successfully created');
$this->endpoint = $endpoint;
}