function FileManagedFileElementTest::testFileNameTrim
Same name in other branches
- 9 core/modules/file/tests/src/Functional/FileManagedFileElementTest.php \Drupal\Tests\file\Functional\FileManagedFileElementTest::testFileNameTrim()
- 10 core/modules/file/tests/src/Functional/FileManagedFileElementTest.php \Drupal\Tests\file\Functional\FileManagedFileElementTest::testFileNameTrim()
- 11.x core/modules/file/tests/src/Functional/FileManagedFileElementTest.php \Drupal\Tests\file\Functional\FileManagedFileElementTest::testFileNameTrim()
Tests file names have leading . removed.
File
-
core/
modules/ file/ tests/ src/ Functional/ FileManagedFileElementTest.php, line 164
Class
- FileManagedFileElementTest
- Tests the 'managed_file' element type.
Namespace
Drupal\Tests\file\FunctionalCode
public function testFileNameTrim() {
file_put_contents('public://.leading-period.txt', $this->randomString(32));
$last_fid_prior = $this->getLastFileId();
$this->drupalPostForm('file/test/0/0/0', [
'files[file]' => \Drupal::service('file_system')->realpath('public://.leading-period.txt'),
], t('Save'));
$next_fid = $this->getLastFileId();
$this->assertGreaterThan($last_fid_prior, $next_fid);
$file = File::load($next_fid);
$this->assertEquals('leading-period.txt', $file->getFilename());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.