class EntityAliasTest

Same name and namespace in other branches
  1. 11.x core/modules/path_alias/tests/src/Kernel/EntityAliasTest.php \Drupal\Tests\path_alias\Kernel\EntityAliasTest

Tests path alias on entities.

@group path_alias

Hierarchy

Expanded class hierarchy of EntityAliasTest

File

core/modules/path_alias/tests/src/Kernel/EntityAliasTest.php, line 16

Namespace

Drupal\Tests\path_alias\Kernel
View source
class EntityAliasTest extends KernelTestBase {
  use PathAliasTestTrait;
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'path_alias',
    'entity_test',
    'user',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->installEntitySchema('entity_test');
    $this->installEntitySchema('path_alias');
    $this->installEntitySchema('user');
  }
  
  /**
   * Tests transform.
   */
  public function testEntityAlias() : void {
    EntityTest::create([
      'id' => 1,
    ])->save();
    $this->createPathAlias('/entity_test/1', '/entity-alias');
    $entity = EntityTest::load(1);
    $this->assertSame('/entity-alias', $entity->toUrl()
      ->toString());
  }

}

Members

Title Sort descending Modifiers Object type Summary
EntityAliasTest::$modules protected static property Modules to install.
EntityAliasTest::setUp protected function
EntityAliasTest::testEntityAlias public function Tests transform.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.