You are here

public function FileLinkRedirectTest::testRedirects in File Link 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/FileLinkRedirectTest.php \Drupal\Tests\file_link\Functional\FileLinkRedirectTest::testRedirects()

Tests redirects.

@dataProvider redirectDataProvider

Parameters

string $path: Path to request.

int $size: Expected file size.

$format: Expected file format.

Throws

\Drupal\Core\Entity\EntityStorageException

\Drupal\Core\TypedData\Exception\MissingDataException

File

tests/src/Functional/FileLinkRedirectTest.php, line 46

Class

FileLinkRedirectTest
Provides functional tests for 'file_link' field type.

Namespace

Drupal\Tests\file_link\Functional

Code

public function testRedirects($path, $size, $format) {
  $entity = EntityTest::create([
    'name' => 'Foo',
    'type' => 'article',
  ]);
  $entity
    ->set('url_without_extension', [
    'uri' => Url::fromUri('base:' . $path, [
      'absolute' => TRUE,
    ])
      ->toString(),
  ]);
  $entity
    ->save();

  /** @var \Drupal\file_link\Plugin\Field\FieldType\FileLinkItem $file_link */
  $file_link = $entity
    ->get('url_without_extension')
    ->first();
  $this
    ->assertEquals($size, $file_link
    ->getSize());
  $this
    ->assertEquals($format, $file_link
    ->getFormat());
}