You are here

public function ServicesResourceNodetests::testEndpointResourceNodeUpdatePermFail in Services 6.3

Same name and namespace in other branches
  1. 7.3 tests/functional/ServicesResourceNodeTests.test \ServicesResourceNodetests::testEndpointResourceNodeUpdatePermFail()

testing node_resource Update fail with no permissions

File

tests/functional/ServicesResourceNodeTests.test, line 447

Class

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

Code

public function testEndpointResourceNodeUpdatePermFail() {

  // Create and log in our privileged user.
  $this->privilegedUser = $this
    ->drupalCreateUser(array(
    'administer services',
    'create story content',
    'edit own story content',
  ));
  $this
    ->drupalLogin($this->privilegedUser);

  // Create node from user no 1.
  $node = $this
    ->drupalCreateNode(array(
    'uid' => 1,
  ));

  // Try to update this node with different user not
  // having permission to edit any story content.
  $node_update = array(
    'title' => 'testing',
    'body' => 'bodytest',
    'type' => 'page',
  );
  $responseArray = $this
    ->servicesPut($this->endpoint->path . '/node/' . $node->nid, $node_update);
  $this
    ->assertTrue(strpos($responseArray['status'], 'Access denied for user'), t('Updating the node failed without needed permissions. This is good!'), 'NodeResource: Update');
}