public function FileFieldAnonymousSubmissionTest::testAnonymousNode in Drupal 8
Same name and namespace in other branches
- 9 core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php \Drupal\Tests\file\Functional\FileFieldAnonymousSubmissionTest::testAnonymousNode()
- 10 core/modules/file/tests/src/Functional/FileFieldAnonymousSubmissionTest.php \Drupal\Tests\file\Functional\FileFieldAnonymousSubmissionTest::testAnonymousNode()
Tests the basic node submission for an anonymous visitor.
File
- core/
modules/ file/ tests/ src/ Functional/ FileFieldAnonymousSubmissionTest.php, line 36
Class
- FileFieldAnonymousSubmissionTest
- Confirm that file field submissions work correctly for anonymous visitors.
Namespace
Drupal\Tests\file\FunctionalCode
public function testAnonymousNode() {
$bundle_label = 'Article';
$node_title = 'test page';
// Load the node form.
$this
->drupalLogout();
$this
->drupalGet('node/add/article');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertText(strip_tags(t('Create @name', [
'@name' => $bundle_label,
])));
$edit = [
'title[0][value]' => $node_title,
'body[0][value]' => 'Test article',
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$t_args = [
'@type' => $bundle_label,
'%title' => $node_title,
];
$this
->assertText(strip_tags(t('@type %title has been created.', $t_args)), 'The node was created.');
$matches = [];
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.');
}
}