You are here

public function FileFieldPathsTokensTest::testTokensMoved in File (Field) Paths 8

Test token values with a moved text file.

File

tests/src/Functional/FileFieldPathsTokensTest.php, line 47

Class

FileFieldPathsTokensTest
Test token functionality.

Namespace

Drupal\Tests\filefield_paths\Functional

Code

public function testTokensMoved() {

  // Prepare a test text file.

  /** @var \Drupal\file\Entity\File $text_file */
  $text_file = $this
    ->getTestFile('text');
  $text_file
    ->save();

  // Move the text file.
  $moved_file = file_move($text_file, 'public://moved.diff');

  // Ensure tokens are processed correctly.
  $data = [
    'file' => $moved_file,
  ];
  $this
    ->assertToken('[file:ffp-name-only]', 'moved', $data);
  $this
    ->assertToken('[file:ffp-name-only-original]', 'text-0', $data);
  $this
    ->assertToken('[file:ffp-extension-original]', 'txt', $data);
}