You are here

public function ServicesResourceWebformTests::setUp in Webform Service 7.4

Implementation of setUp().

Overrides ServicesWebTestCase::setUp

File

tests/ServicesResourceWebformTests.test, line 35

Class

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

Code

public function setUp() {
  parent::setUp('webform', 'webform_service', 'uuid');
  $edit = $this
    ->populateEndpointFAPI();
  $this->endpoint = new stdClass();
  $this->endpoint->disabled = FALSE;

  /* Edit this to true to make a default endpoint disabled initially */
  $this->endpoint->api_version = 3;
  $this->endpoint->name = $edit['name'];
  $this->endpoint->server = $edit['server'];
  $this->endpoint->path = $edit['path'];
  $this->endpoint->authentication = array(
    'services' => 'services',
  );
  $this->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,
    ),
  );
  $this->endpoint->resources = array(
    'submission' => array(
      'operations' => array(
        'create' => array(
          'enabled' => 1,
        ),
        'retrieve' => array(
          'enabled' => 1,
        ),
        'update' => array(
          'enabled' => 1,
        ),
        'retrieve' => array(
          'enabled' => 1,
        ),
        'delete' => array(
          'enabled' => 1,
        ),
      ),
    ),
  );

  // Get all the webform types.
  $types = webform_variable_get('webform_node_types');

  // Iterate through the webform types.
  foreach ($types as $type) {
    $this->endpoint->resources[$type] = array(
      'operations' => array(
        'create' => array(
          'enabled' => 1,
        ),
        'retrieve' => array(
          'enabled' => 1,
        ),
        'update' => array(
          'enabled' => 1,
        ),
        'delete' => array(
          'enabled' => 1,
        ),
        'index' => array(
          'enabled' => 1,
        ),
      ),
      'relationships' => array(
        'submissions' => array(
          'enabled' => 1,
        ),
      ),
    );
  }
  $this->endpoint->resources['submission'] = array(
    'operations' => array(
      'create' => array(
        'enabled' => 1,
      ),
      'retrieve' => array(
        'enabled' => 1,
      ),
      'update' => array(
        'enabled' => 1,
      ),
      'delete' => array(
        'enabled' => 1,
      ),
    ),
  );
  $this->endpoint->debug = 1;
  $this->endpoint->export_type = FALSE;
  services_endpoint_save($this->endpoint);
  $endpoint = services_endpoint_load($this->endpoint->name);
  $this
    ->assertTrue($endpoint->name == $edit['name'], t('Endpoint successfully created'));
}