public function FileManagedFileElementTest::testFileNameTrim in Drupal 8
Same name and namespace 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()
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());
}