You are here

public function LinkitFilterEntityTest::testFilterFileEntity in Linkit 8.5

Tests the linkit filter for file entities.

File

tests/src/Kernel/LinkitFilterEntityTest.php, line 119

Class

LinkitFilterEntityTest
Tests the Linkit filter.

Namespace

Drupal\Tests\linkit\Kernel

Code

public function testFilterFileEntity() {
  $file = File::create([
    'uid' => 1,
    'filename' => 'druplicon.txt',
    'uri' => 'public://druplicon.txt',
    'filemime' => 'text/plain',
    'status' => FILE_STATUS_PERMANENT,
  ]);
  $file
    ->save();

  // Disable the automatic title attribute.
  $this->filter
    ->setConfiguration([
    'settings' => [
      'title' => 0,
    ],
  ]);
  $this
    ->assertLinkitFilter($file);

  // Automatically set the title.
  $this->filter
    ->setConfiguration([
    'settings' => [
      'title' => 1,
    ],
  ]);
  $this
    ->assertLinkitFilterWithTitle($file);
}