function FileFieldAnonymousSubmission::testAnonymousNode in Drupal 7
Tests the basic node submission for an anonymous visitor.
File
- modules/
file/ tests/ file.test, line 1730 - Tests for file.module.
Class
- FileFieldAnonymousSubmission
- Confirm that file field submissions work correctly for anonymous visitors.
Code
function testAnonymousNode() {
$bundle_label = 'Article';
$node_title = 'Test page';
// Load the node form.
$this
->drupalGet('node/add/article');
$this
->assertResponse(200, 'Loaded the article node form.');
$this
->assertText(strip_tags(t('Create @name', array(
'@name' => $bundle_label,
))));
$edit = array(
'title' => $node_title,
'body[und][0][value]' => 'Test article',
'body[und][0][format]' => 'filtered_html',
);
$this
->drupalPost(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.');
}
}