You are here

protected function EntityResourceTestBase::getEntityResourceUrl in Drupal 9

Same name and namespace in other branches
  1. 8 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.

5 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
Tests 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.
TermResourceTestBase::testGetTermWithParent in core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
Tests GETting a term with a parent term other than the default <root> (0).

File

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

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());
}