function EntityViewsDataTest::testEntityLinks

Tests add link types.

File

core/modules/views/tests/src/Unit/EntityViewsDataTest.php, line 966

Class

EntityViewsDataTest
@coversDefaultClass \Drupal\views\EntityViewsData @group Views

Namespace

Drupal\Tests\views\Unit

Code

public function testEntityLinks() {
    $this->baseEntityType
        ->setLinkTemplate('canonical', '/entity_test/{entity_test}');
    $this->baseEntityType
        ->setLinkTemplate('edit-form', '/entity_test/{entity_test}/edit');
    $this->baseEntityType
        ->setLinkTemplate('delete-form', '/entity_test/{entity_test}/delete');
    $data = $this->viewsData
        ->getViewsData();
    foreach ([
        'entity_test',
        'entity_test_revision',
    ] as $table_name) {
        $this->assertEquals('entity_link', $data[$table_name]['view_entity_test']['field']['id']);
        $this->assertEquals('entity_link_edit', $data[$table_name]['edit_entity_test']['field']['id']);
        $this->assertEquals('entity_link_delete', $data[$table_name]['delete_entity_test']['field']['id']);
    }
}

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