public function SubstitutionPluginTest::testFileSubstitutions in Linkit 8.5
Test the file substitution.
File
- tests/
src/ Kernel/ SubstitutionPluginTest.php, line 102
Class
- SubstitutionPluginTest
- Tests the substitution plugins.
Namespace
Drupal\Tests\linkit\KernelCode
public function testFileSubstitutions() {
$fileSubstitution = $this->substitutionManager
->createInstance('file');
$file = File::create([
'uid' => 1,
'filename' => 'druplicon.txt',
'uri' => 'public://druplicon.txt',
'filemime' => 'text/plain',
'status' => FILE_STATUS_PERMANENT,
]);
$file
->save();
$this
->assertEquals($GLOBALS['base_url'] . '/' . $this->siteDirectory . '/files/druplicon.txt', $fileSubstitution
->getUrl($file)
->getGeneratedUrl());
$entity_type = $this->entityTypeManager
->getDefinition('file');
$this
->assertTrue(FileSubstitutionPlugin::isApplicable($entity_type), 'The entity type File is applicable the file substitution.');
$entity_type = $this->entityTypeManager
->getDefinition('entity_test');
$this
->assertFalse(FileSubstitutionPlugin::isApplicable($entity_type), 'The entity type EntityTest is not applicable the file substitution.');
}