1 file.test public FileFieldAnonymousSubmission::testAnonymousNode()

Tests the basic node submission for an anonymous visitor.

File

core/modules/file/tests/file.test, line 1955
Tests for file.module.

Class

FileFieldAnonymousSubmission
Confirm that file field submissions work correctly for anonymous visitors.

Code

public function testAnonymousNode() {
  $bundle_label = 'Page';
  $node_title = 'Test page';

  // Load the node form.
  $this->backdropGet('node/add/page');
  $this->assertResponse(200, 'Loaded the page node form.');
  $this->assertText(strip_tags(t('Create @name', array('@name' => $bundle_label))));

  $edit = array(
    'title' => $node_title,
    'body[und][0][value]' => 'Test page',
    'body[und][0][format]' => 'filtered_html',
    'path[auto]' => FALSE,
    'path[alias]' => '',
  );
  $this->backdropPost(NULL, $edit, t('Save'));
  $this->assertResponse(200);
  $t_args = array('@type' => $bundle_label, '%title' => $node_title);
  $this->assertText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.');
  $matches = array();
  if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) {
    $nid = end($matches);
    $this->assertNotEqual($nid, 0, 'The node ID was extracted from the URL.');
    $node = node_load($nid);
    $this->assertNotEqual($node, NULL, 'The node was loaded successfully.');
  }
}