You are here

protected function FileMatcherTest::setUp in Linkit 8.5

Overrides LinkitKernelTestBase::setUp

File

tests/src/Kernel/Matchers/FileMatcherTest.php, line 32

Class

FileMatcherTest
Tests file matcher.

Namespace

Drupal\Tests\linkit\Kernel\Matchers

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('file');
  $this
    ->installSchema('system', [
    'key_value_expire',
  ]);
  $this
    ->installSchema('file', [
    'file_usage',
  ]);
  $this->manager = $this->container
    ->get('plugin.manager.linkit.matcher');

  // Linkit doesn't care about the actual resource, only the entity.
  foreach ([
    'gif',
    'jpg',
    'png',
  ] as $ext) {
    $file = File::create([
      'uid' => 1,
      'filename' => 'image-test.' . $ext,
      'uri' => 'public://image-test.' . $ext,
      'filemime' => 'text/plain',
      'status' => FILE_STATUS_PERMANENT,
    ]);
    $file
      ->save();
  }

  // Create user 1 who has special permissions.
  \Drupal::currentUser()
    ->setAccount($this
    ->createUser([
    'uid' => 1,
  ]));
}