public function SubstitutionPluginTest::testCanonicalSubstitution in Linkit 8.5
Test the canonical substitution.
File
- tests/
src/ Kernel/ SubstitutionPluginTest.php, line 124
Class
- SubstitutionPluginTest
- Tests the substitution plugins.
Namespace
Drupal\Tests\linkit\KernelCode
public function testCanonicalSubstitution() {
$canonicalSubstitution = $this->substitutionManager
->createInstance('canonical');
$entity = EntityTest::create([]);
$entity
->save();
$this
->assertEquals('/entity_test/1', $canonicalSubstitution
->getUrl($entity)
->getGeneratedUrl());
$entity_type = $this->entityTypeManager
->getDefinition('entity_test');
$this
->assertTrue(CanonicalSubstitutionPlugin::isApplicable($entity_type), 'The entity type EntityTest is applicable the canonical substitution.');
$entity_type = $this->entityTypeManager
->getDefinition('file');
$this
->assertFalse(CanonicalSubstitutionPlugin::isApplicable($entity_type), 'The entity type File is not applicable the canonical substitution.');
}