function ManageFieldsFunctionalTest::testInvalidUrlsAndDestinations
Tests invalid field UI URLs and destinations.
File
-
core/
modules/ field_ui/ tests/ src/ Functional/ ManageFieldsFunctionalTest.php, line 262
Class
- ManageFieldsFunctionalTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\Tests\field_ui\FunctionalCode
public function testInvalidUrlsAndDestinations() : void {
$field_id = 'node.foo.bar';
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
$this->assertSession()
->statusCodeEquals(404);
$options = [
'query' => [
'destinations' => [
'http://example.com',
],
],
];
$this->drupalGet('admin/structure/types/manage/article/fields/node.article.body', $options);
$this->submitForm([], 'Save settings');
// The external redirect should not fire.
$url = parse_url($this->getSession()
->getCurrentUrl());
$this->assertStringEndsWith('/admin/structure/types/manage/article/fields/node.article.body', $url['path']);
$query = [];
parse_str($url['query'], $query);
$this->assertSame([
'http://example.com',
], $query['destinations']);
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->responseContains('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component 'http://example.com' is external. You are not allowed to specify an external URL together with internal:/.</em>.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.