You are here

public function ServicesResourceWebformTests::testNewEndpointWebformGet in Webform Service 7.4

testing node_resource Get

File

tests/ServicesResourceWebformTests.test, line 229

Class

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

Code

public function testNewEndpointWebformGet() {
  $types = webform_variable_get('webform_node_types');

  // Create and log in our privileged user.
  $this->privilegedUser = $this
    ->drupalCreateUser(array(
    'administer services',
  ));
  $this
    ->drupalLogin($this->privilegedUser);
  $node = $this
    ->drupalCreateNode(array(
    'type' => $types[0],
  ));

  // Get the endpoint.
  $endpoint = $this->endpoint->path . '/' . $types[0];
  $responseArray = $this
    ->servicesGet($endpoint . '/' . $node->uuid);
  $this
    ->assertTrue($node->title == $responseArray['body']->title, t('Successfully received Webform'), 'Webform: Retrieve');

  //Verify node not found.
  unset($node);
  $responseArray = $this
    ->servicesGet($endpoint . '/1234');
  $this
    ->assertTrue($responseArray['code'] == '404', t('Successfully was rejected to non existent webform'), 'Webform: Retrieve');
}