function EntityResourceTestBase::getEntityResourceUrl

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getEntityResourceUrl()
  2. 10 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getEntityResourceUrl()
  3. 11.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getEntityResourceUrl()

Gets an entity resource's GET/PATCH/DELETE URL.

Return value

\Drupal\Core\Url The URL to GET/PATCH/DELETE.

6 calls to EntityResourceTestBase::getEntityResourceUrl()
EntityResourceTestBase::testDelete in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a DELETE request for an entity, plus edge cases to ensure good DX.
EntityResourceTestBase::testGet in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Test a GET request for an entity, plus edge cases to ensure good DX.
EntityResourceTestBase::testPatch in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a PATCH request for an entity, plus edge cases to ensure good DX.
EntityTestTextItemNormalizerTest::testGetWithFormat in core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php
Tests GETting an entity with the test text field set to a specific format.
FileHalJsonAnonTest::testGetBcUriField in core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php
@group legacy @expectedDeprecation Replacing the file uri with the URL is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the provided url property instead and disable hal.settings:bc_file_uri_as_url_normalizer. See…

... See full list

File

core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php, line 1425

Class

EntityResourceTestBase
Even though there is the generic EntityResource, it's necessary for every entity type to have its own test, because they each have different fields, validation constraints, et cetera. It's not because the generic case works, that every case…

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

protected function getEntityResourceUrl() {
    $has_canonical_url = $this->entity
        ->hasLinkTemplate('canonical');
    // Note that the 'canonical' link relation type must be specified explicitly
    // in the call to ::toUrl(). 'canonical' is the default for
    // \Drupal\Core\Entity\Entity::toUrl(), but ConfigEntityBase overrides this.
    return $has_canonical_url ? $this->entity
        ->toUrl('canonical') : Url::fromUri('base:entity/' . static::$entityTypeId . '/' . $this->entity
        ->id());
}

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