You are here

function RestWSTestCase::testBadRequests in RESTful Web Services 7

Same name and namespace in other branches
  1. 7.2 restws.test \RestWSTestCase::testBadRequests()

Tests bad requests.

File

./restws.test, line 78
RESTful web services tests.

Class

RestWSTestCase
@file RESTful web services tests.

Code

function testBadRequests() {

  // Assure that nodes without types won't be created.
  $account = $this
    ->drupalCreateUser(array(
    'access content',
    'bypass node access',
    'access resource node',
    'administer users',
  ));
  $title = $this
    ->randomName(8);
  $new_node = array(
    'body' => array(
      LANGUAGE_NONE => array(
        array(),
      ),
    ),
    'title' => $title,
  );
  $json = drupal_json_encode($new_node);
  $result = $this
    ->httpRequest('node', 'PUT', $account, $json);
  $node = entity_load('node', FALSE, array(
    'title' => $title,
  ));
  $this
    ->assertEqual(count($node), 0, "Node wasn't created");
  $this
    ->assertResponse('406', 'Missing bundle: type');
}