public function FileManagedFileElementTest::testFileNameTrim in Drupal 9
Same name and namespace in other branches
- 8 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 170
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
->drupalGet('file/test/0/0/0');
$this
->submitForm([
'files[file]' => \Drupal::service('file_system')
->realpath('public://.leading-period.txt'),
], 'Save');
$next_fid = $this
->getLastFileId();
$this
->assertGreaterThan($last_fid_prior, $next_fid);
$file = File::load($next_fid);
$this
->assertEquals('leading-period.txt', $file
->getFilename());
}