You are here

public function ServicesEntityTestHelper::saveNewEndpoint in Services Entity API 7.2

Need to override this :(

@todo: Remove when https://drupal.org/node/2089445 is fixed.

Parameters

array $resources: A list of the resources which should be added.

Overrides ServicesWebTestCase::saveNewEndpoint

2 calls to ServicesEntityTestHelper::saveNewEndpoint()
ServicesEntityGenericEntityResource::setUp in tests/services_entity.test
Implements setUp().
ServicesEntityNodeResourceTest::setUp in tests/services_entity.test
Sets up a Drupal site for running functional and integration tests.

File

tests/services_entity.test, line 18
Services Entity Tests

Class

ServicesEntityTestHelper
Services Entity Test Helper class.

Code

public function saveNewEndpoint(array $resources) {
  $edit = $this
    ->populateEndpointFAPI();
  $edit['path'] = 'endpoint';
  $edit['title'] = 'WT??';
  $endpoint = new stdClass();
  $endpoint->disabled = FALSE;

  /* Edit this to true to make a default endpoint disabled initially */
  $endpoint->api_version = 3;
  $endpoint->name = $edit['name'];
  $endpoint->title = $edit['title'];
  $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,
    ),
  );
  $endpoint->resources = array(
    'system' => array(
      'alias' => '',
      'actions' => array(
        'connect' => array(
          'enabled' => 1,
        ),
        'get_variable' => array(
          'enabled' => 1,
        ),
        'set_variable' => array(
          'enabled' => 1,
        ),
      ),
    ),
    'user' => array(
      'alias' => '',
      'operations' => array(
        'create' => array(
          'enabled' => 1,
        ),
        'retrieve' => array(
          'enabled' => 1,
        ),
        'update' => array(
          'enabled' => 1,
        ),
        'delete' => array(
          'enabled' => 1,
        ),
        'index' => array(
          'enabled' => 1,
        ),
      ),
      'actions' => array(
        'login' => array(
          'enabled' => 1,
        ),
        'logout' => array(
          'enabled' => 1,
        ),
      ),
    ),
  );
  foreach ($resources as $resource) {

    // @todo Add other operations besides CRUD.
    $endpoint->resources += array(
      $resource => array(
        'operations' => array(
          'retrieve' => array(
            'enabled' => 1,
          ),
          'create' => array(
            'enabled' => 1,
          ),
          'update' => array(
            'enabled' => 1,
          ),
          'delete' => array(
            'enabled' => 1,
          ),
          'index' => 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');
  return $endpoint;
}