function ManagedFileFidValidationTest::testOtherUsersFileIdNotAcceptedViaUrl
Same name and namespace in other branches
- 11.x core/modules/file/tests/src/Functional/ManagedFileFidValidationTest.php \Drupal\Tests\file\Functional\ManagedFileFidValidationTest::testOtherUsersFileIdNotAcceptedViaUrl()
Tests that other users' file IDs are rejected when passed via URL.
File
-
core/
modules/ file/ tests/ src/ Functional/ ManagedFileFidValidationTest.php, line 82
Class
- ManagedFileFidValidationTest
- Tests the file validation in the ManagedFile element for private files.
Namespace
Drupal\Tests\file\FunctionalCode
public function testOtherUsersFileIdNotAcceptedViaUrl() : void {
$this->drupalLogin($this->anotherUser);
$owner_fid = $this->ownerFile
->id();
// Visit the form with the other user's file ID in the URL.
$this->drupalGet('file/test/1/1/1/' . $owner_fid);
$this->submitForm([], 'Save');
$this->getSession()
->getPage()
->getText();
$this->assertSession()
->pageTextContains('The file ids are');
$response = $this->getSession()
->getPage()
->getText();
$this->assertStringNotContainsString("The file ids are {$owner_fid}.", $response);
$this->assertSession()
->pageTextContains('The file ids are .');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.