public function FileLinkRedirectTest::testRedirects in File Link 2.0.x
Same name and namespace in other branches
- 8 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 51
Class
- FileLinkRedirectTest
- Tests the redirect functionality of the 'file_link' field type.
Namespace
Drupal\Tests\file_link\FunctionalCode
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());
}