public function FileFieldPathsTokensTest::testTokensBasic in File (Field) Paths 8
Test token values with a text file.
File
- tests/
src/ Functional/ FileFieldPathsTokensTest.php, line 31
Class
- FileFieldPathsTokensTest
- Test token functionality.
Namespace
Drupal\Tests\filefield_paths\FunctionalCode
public function testTokensBasic() {
// Prepare a test text file.
/** @var \Drupal\file\Entity\File $text_file */
$text_file = $this
->getTestFile('text');
$text_file
->save();
// Ensure tokens are processed correctly.
$data = [
'file' => $text_file,
];
$this
->assertToken('[file:ffp-name-only]', 'text-0', $data);
$this
->assertToken('[file:ffp-name-only-original]', 'text-0', $data);
$this
->assertToken('[file:ffp-extension-original]', 'txt', $data);
}